Hi,
I want my website to auto refresh after member login,
i am restricting some pages in my website, and they are getting visible after login ,( but only after manually refreshing the website. )I don't want user to refresh the website. is there any way to auto refresh my website in code behind, it would be great if someone help me out ,thank you in advance.
So how do you submit above login functionality? I guess you use some javascript logic to handle that...
I think it would be much better to use some Umbraco form with Surface controller. Then the page reload would be handled automatically with POST request...
The View:
@{
var loginModel = new CustomLoginModel();
}
@using (Html.BeginUmbracoForm<LoginController>("HandleLogin", null, new { @class = "login-form" }))
{
@Html.LabelFor(m => loginModel.Username)
@Html.ValidationMessageFor(m => loginModel.Username, null, new {@class = "validation-message"})
@Html.TextBoxFor(m => loginModel.Username, new {@class = "form-control"})
@Html.LabelFor(m => loginModel.Password)
@Html.ValidationMessageFor(m => loginModel.Password, null, new {@class = "validation-message"})
@Html.PasswordFor(m => loginModel.Password, new {@class = "form-control"})
<button type="submit" class="btn btn-primary">Sign in</button>
}
The controller:
public class LoginController : SurfaceController
{
[HttpPost]
public ActionResult HandleLogin([Bind(Prefix = "loginModel")]CustomLoginModel model)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.Username, model.Password))
{
FormsAuthentication.SetAuthCookie(model.Username, true);
return RedirectToCurrentUmbracoPage();
}
}
TempData["LoginFailed"] = true;
return CurrentUmbracoPage();
}
}
refresh the umbraco website after member login
Hi, I want my website to auto refresh after member login, i am restricting some pages in my website, and they are getting visible after login ,( but only after manually refreshing the website. )I don't want user to refresh the website. is there any way to auto refresh my website in code behind, it would be great if someone help me out ,thank you in advance.
Could you clarify, do you mean Umbraco backoffice member or website user?
How do you handle the login form? It would be nice to see some your code snippets...
sure,I want to refresh/reload current page after user login
here is my snippet, it is working fine , the only thing is i need to refresh the page.
So how do you submit above login functionality? I guess you use some javascript logic to handle that...
I think it would be much better to use some Umbraco form with Surface controller. Then the page reload would be handled automatically with POST request...
The View:
The controller:
Thank you raibow, but where should i put the controller code , I am driving my code from umbraco back office , not from visual studio MVC application.
In that case you basically can't use it. That's because before you could use it you have to compile it.
You can use then the default Umbraco login controller. Please do as described below:
is working on a reply...