wait...where should I use it>? I have asp.net mvc background so I understand that this should go to controllers...but I don't have any controllers :/ this is my project (after downloading it)
ok. You can create your views and partials in visual studio that will appear in the admin panel (Back-Office). Except controller and models, only in visual studio. Any questions post here.
Will depend on the structure of your site . You can create a DocumentType for Login and create your content named login. The template for login has this code: @Html.Action("MemberLogin","MemberLoginSurface")
Hi, added a new document and I pased there the line you showed and I'm still getting the error "
Server Error in '/' Application.
No route in the route table matches the supplied values.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: No route in the route table matches the supplied values.
Source Error:
Line 1: This is member login page
Line 2: @Html.Action("MemberLogin","MemberLoginSurface")
Should I "tell" Umbraco that I created a new controller and he should be aware of it? Or its automatically done?
[HttpPost]
public ActionResult Login(LoginModelView model)
{
if (Membership.ValidateUser(model.Username, model.Password))
{
FormsAuthentication.SetAuthCookie(model.Username, true);
var roles = System.Web.Security.Roles.GetRolesForUser();
var cur = UmbracoContext.Security.CurrentUser;
both the roles and cur are null.... (of course the user exists and its validated properly).
Generally what now I want to do:
I will have 2 master pages: A and B.
Page A belongs to Agroup
Page B belongs to Bgroup.
When user logs in, I want to redirect him to the master page that he belongs to, for example the user A, from GroupA redirects to Page A. How can I achieve that?
Second Issue:
In POST of Login funtionality I have this:
[HttpPost]
public ActionResult Login(LoginModelView model)
{
if (Membership.ValidateUser(model.Username, model.Password))
{
FormsAuthentication.SetAuthCookie(model.Username, true);
var roles = System.Web.Security.Roles.GetRolesForUser();
var cur = UmbracoContext.Security.CurrentUser;
return RedirectToCurrentUmbracoPage();
}
TempData["Status"] = "Invalid username or password";
return RedirectToCurrentUmbracoPage();
}
when I'm calling this from view, I have an error saying:
Cannot redirect from a Child Action
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Cannot redirect from a Child Action
Source Error:
Line 3: Layout = "umbLayout.cshtml";
Line 4: }
Line 5: @Html.Action("Login","AccountSurface")
Redirect after login
Hello,
how can I redirect user to certain page after the login process is successful ?
Hi Krisek,
WebForms or MVC?
MVC, sorry
Use it in the return of action:
return Redirect("url");
This site has a great example
http://24days.in/umbraco/2012/creating-a-login-form-with-umbraco-mvc-surfacecontroller/
wait...where should I use it>? I have asp.net mvc background so I understand that this should go to controllers...but I don't have any controllers :/ this is my project (after downloading it)
Krisek,
I always create a Controller class in App_Code . In this folder you can create by following the example of 24days site.
Okay, so step by step.
I totally didn't understand this:ple of 24days site what did you meant?
So in App_Code I can create my own controller. thats good, I assume that this controller will inherit from SurfaceController-correct?
So what should I write there to connect my existing Login page?
Or maybe I should create a new one?
I meant the website link.
Yes. Their Controller must inherit the SurfaceController
You can use the helper to create your form in the view or partial . @Html.BeginUmbracoForm<MySurfaceController>(...)
what version of umbraco ?
the latest one which u can download. 7 something i think.
Look, I will go through this website u send me the link and if I step on any problem i will post here :)
I'm not sure: i will add the controller+views +models (through the visual studio) and the will simply come up in the admin panel in web browser?>
ok. You can create your views and partials in visual studio that will appear in the admin panel (Back-Office). Except controller and models, only in visual studio. Any questions post here.
regards!
I did as the tutorial was saying, but in my backend I don't see the new View (LoginMember in Partial folder).
Where should I add this: @Html.Action("MemberLogin","MemberLoginSurface") ?
that line of code i put into Master template, then I tried to put it into some other template. I'm getting this error:
then I moved the controller from folder App_Code to "Controllers" (i created that folder) and this is the error:
Hi,
what is the name of the controller?
you created a partial?
I do not understand why you're calling a @Html.Action.
Please, paste here the code of model , view and controller.
I did this tutorial: http://24days.in/umbraco/2012/creating-a-login-form-with-umbraco-mvc-surfacecontroller/
so the model:
controller:
In the code the return of Action MemberLogin is a type View. Change so.
return PartialView("MemberLogin", new MemberLoginModel());
Okay that looks promising, tell me please where should I call it and how?
for example let's say that I want to create from the backend admin panel a new content site and use it there
Will depend on the structure of your site . You can create a DocumentType for Login and create your content named login. The template for login has this code:
@Html.Action("MemberLogin","MemberLoginSurface")
Hi, added a new document and I pased there the line you showed and I'm still getting the error "
Server Error in '/' Application.
No route in the route table matches the supplied values.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: No route in the route table matches the supplied values.
Source Error:
Line 2: @Html.Action("MemberLogin","MemberLoginSurface")
Should I "tell" Umbraco that I created a new controller and he should be aware of it? Or its automatically done?
I started the project again, from scratch and now its working fine :(
don't know the issue, but thanks for the whole help! :)
There is an alternative which is simpler but works well . You create a script file and use this code https://gist.github.com/joeriks/874194 as a macro.
regards!
Now I have different problem.
1. First of all I did this:
Cannot redirect from a Child Action
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.InvalidOperationException: Cannot redirect from a Child Action
Source Error:
Line 3: Layout = "umbLayout.cshtml"; Line 4: } Line 5: @Html.Action("Login","AccountSurface")
is working on a reply...