Friday, 15 March 2013

c# - ASP.NET MVC 4 Routing issues -



c# - ASP.NET MVC 4 Routing issues -

i trying url in browser:

http://localhost:41359/account/login

here routes routeconfig.cs:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; using system.web.routing; namespace cthrc.roti.web.ui { public class routeconfig { public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "account", url: "account/{action}/{id}", defaults: new { controller = "account", action = "login", id = urlparameter.optional } ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); } } }

but when seek goto url in browser, error:

{"message":no http resource found matches request uri 'http://localhost:41359/account'.","messagedetail":"no type found matches controller named 'account'."}

everything seems right here, still error. here accountcontroller:

using system; using system.collections.generic; using system.linq; using system.web; using system.web.mvc; using webmatrix.webdata; using cthrc.roti.domain.api.services; namespace cthrc.roti.web.ui.controllers { public class accountcontroller : controller { [httpget] public actionresult login() { if (!websecurity.initialized) { websecurity.initializedatabaseconnection("modelcontext", "users", "id", "username", autocreatetables: true); } homecoming view(); } [httppost] public actionresult login(formcollection form) { bool success = websecurity.login(form["username"], form["password"], false); if (success) { string returnurl = request.querystring["returnurl"]; if (returnurl == null) { response.redirect("/home/index?userid=" + websecurity.currentuserid); } else { response.redirect(returnurl); } } homecoming view(); } [httpget] public actionresult register() { if (!websecurity.initialized) { websecurity.initializedatabaseconnection("userdb", "users", "id", "username", autocreatetables: true); } homecoming view(); } [httppost] public actionresult register(formcollection form) { websecurity.createuserandaccount(form["username"], form["password"], new { email = form["email"], language = form["language"] }); response.redirect("/account/login"); homecoming view(); } public actionresult logout() { websecurity.logout(); response.redirect("/account/login"); homecoming view(); } } }

i have been struggling issue days now, have cleaned solution, re-built solution , built solution , still error. if can help me much appreciated. in advance.

c# asp.net asp.net-mvc-4 asp.net-mvc-routing

No comments:

Post a Comment