c# - How to start Login screen which is in MVC 5 Areas by default -


i have login screen default located @ mvc 5 areas area x.

i share code please review it

my routeconfig

routes.maproute(   name: "default",   url: "x/{controller}/{action}/{id}",   defaults: new { controller = "y", action = "index", id = urlparameter.optional },   namespaces: new[] { "areas.controllers" } ); 

my controller:

public actionresult index() {    return redirecttoaction("login", "y", new { area = "x" }); } 

my root web.config

<authentication mode="forms">       <forms loginurl="~/x/y/index" timeout="2880"></forms> </authentication> 

my area register:

public override void registerarea(arearegistrationcontext context)  {     context.maproute(           "a",           "x/{controller}/{action}/{id}",           defaults: new { action = "index", controller = "user", id =                      urlparameter.optional }     ); } 

my question login screen not getting screen.... when check output login view fine remaining cases doesn't works properly. please me

if i've got straight root/home controller y based on example, , login action based on user controller in area x.

assuming correct routeconfig.cs should this:

routes.maproute(             "default", // route name             "{controller}/{action}/{id}", // url parameters             new { controller = "y", action = "index", id = urlparameter.optional } // parameter defaults         ); 

controller y in controllers folder should this:

public class y : controller {     public actionresult index()     {          return redirecttoaction("login", "user", new { area = "x" });     } } 

your area registration this:

public override void registerarea(arearegistrationcontext context) {     context.maproute(         "x_default",         "x/{controller}/{action}/{id}",         new { controller="user", action = "login",              id = urlparameter.optional }     ); } 

config this:

<authentication mode="forms">   <forms loginurl="~/x/user/login" timeout="2880"></forms> </authentication> 

and in areas/x/controllers folder

public class user : controller {     public actionresult login()     {          // login stuff here     } } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -