c# - AreaRegistration is not working in MVC Razor -
i have added area called blogging in site created stuffs , tried access in browser manually entering url getting error "server error in '/' application.". have attached code , snapshot of project. appreciated.
global.asax
public static void mycustomrouting(routecollection coll) { coll.ignoreroute("{resource}.axd/{*pathinfo}"); coll.maproute("default", "{controller}/{action}", new { controller = "home", action = "index" }, new[] { "areas.controllers" }); } protected void application_start() { //routedebug.routedebugger.rewriteroutesfortesting(routetable.routes); arearegistration.registerallareas(); registerglobalfilters(globalfilters.filters); mycustomrouting(routetable.routes); }
bloggingarearegistration.cs
using system.web.mvc; namespace mvc_pagerouting.areas.blogging { public class bloggingarearegistration : arearegistration { public override string areaname { { return "blogging"; } } public override void registerarea(arearegistrationcontext context) { context.maproute("blogging_default", "blogging/{controller}/{action}/{id}", new {action="index",urlparameter.optional }); } } }
folder structure:
error:
specify id parameter optional adding "id = " front of urlparameter.optional
new {action="index", id = urlparameter.optional }
Comments
Post a Comment