c# - RedirectToAction not working in controller -
following 1 login function in controller:
[httppost] public actionresult login(string email, string password) { return redirecttoaction("index", "home"); } this calls index function of homecontroller same screen i.e login screen remains on browser.
following routes in mvc application :
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( "default", // route name "{controller}/{action}/{id}", // url parameters new { controller = "login", action = "index", id = urlparameter.optional } // parameter defaults ); } i not sure issue. search net there deviance in issue faced other users.
please help.
update:
homecontroller :
public class homecontroller : controller { public actionresult index() { viewbag.message = "modify template jump-start asp.net mvc application."; return view(); } public actionresult about() { viewbag.message = "your app description page."; return view(); } public actionresult contact() { viewbag.message = "your contact page."; return view(); } }
pages such index page on home controller need [allowanonymous] decorating action allow page viewed without logging in.
do this
public class homecontroller : controller { [allowanonymous] public actionresult index() { viewbag.message = "modify template jump-start asp.net mvc application."; return view(); } you need
[httppost] [allowanonymous] public actionresult login(string email, string password) { return redirecttoaction("index", "home"); }
Comments
Post a Comment