c# - Existing asp.net project no new controller function is working, showing 404 -
i working on existing asp.net website , code client server code hosted. able run project in local pc when try add new controller function show http 404. ![enter image description here][1]
for example in accountcontroller.cs there existing login function
// get: /account/login [allowanonymous] public actionresult login(string returnurl) { if (websecurity.isauthenticated == true){ websecurity.logout(); session.abandon(); } viewbag.returnurl = returnurl; return view(); }
then copied function , created new 1 below , duplicated view file , renamed
// // get: /account/aalogin [allowanonymous] public actionresult aalogin(string returnurl) { if (websecurity.isauthenticated == true) { websecurity.logout(); session.abandon(); } viewbag.returnurl = returnurl; return view(); }
global.asax.cs
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( "default", // route name "{controller}/{action}/{id}", // url parameters new { controller = "home", action = "index", id = urlparameter.optional }); routes.maproute( "aalogin", // route name "account/aalogin", // url parameters new { controller = "account", action = "aalogin", id = urlparameter.optional }); }
routeconfig.cs
public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "viewlistingnoauth", url: "{id}", defaults: new { controller = "listing", action = "publicview"} ); routes.maproute( name: "socialmediahooks", url: "externalservice/uploadflyertosocialmedia/{id}/{sname}", defaults: new { controller = "home", action = "index", id = urlparameter.optional, name = urlparameter.optional } ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); }
but still doesn't work when browse /account/aalogin... body can me in or resource can understand.
if can give me idea whats happening happy.
here few troubleshooting steps can try:
- observe call in fiddler. call being fired? if so, match expecting?
- install routedebugger (using nuget) , enable it. great tool see what's going on routes. tell routing rules being hit.
p.s. may want use 1 of "asp.net-mvc" tags similiar questions.
Comments
Post a Comment