c# - ASP.NET 4 MVC Routes 404 -
i getting 404 error on page. missing?
global.asax.cs:
protected void application_start() { arearegistration.registerallareas(); routeconfig.registerroutes(routetable.routes); } in app_start folder routeconfig.cs:
public class routeconfig { public static void registerroutes(routecollection routes) { routes.ignoreroute("{resource}.axd/{*pathinfo}"); routes.maproute( name: "productdetails", url: "products/details", defaults: new { controller = "productdetails", action = "index" } ); routes.maproute( name: "default", url: "{controller}/{action}/{id}", defaults: new { controller = "home", action = "index", id = urlparameter.optional } ); } } in productdetailcontroller.cs have:
public class productdetailscontroller : controller { public actionresult index() { productmodel product = new productmodel(); //some code here return view("~/views/productdetails/index.cshtml", product); } } my view located folder structure , called index.cshtml.
when view page url /products/details/ getting 404 error. missing here? note: umbraco site.
umbraco takes on routes ovveride umbraco create custom routes create class called routinghandler in app_start folder following code:
using system.web.mvc; using system.web.routing; using umbraco.core; public class routinghandler : applicationeventhandler { protected override void applicationstarted(umbracoapplicationbase umbracoapplication, applicationcontext applicationcontext) { registercustomroutes(); } private static void registercustomroutes() { routetable.routes.maproute( name: "productdetails", url: "products/details", defaults: new { controller = "productdetails", action = "index" } ); } }
Comments
Post a Comment