Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC 4 Routing with UrlParameter.Optional expects parameter
    primarykey
    data
    text
    <p>In my MVC solution i have Different areas. One of the area's registration is class is displaied below.</p> <pre><code> public class CommercialAreaRegistration : AreaRegistration { public override string AreaName { get { return "Commercial"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Commercial_default", "Commercial/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional } ); } } </code></pre> <p>Based on this the url <em>hxxp://localhost:63363/Commercial/VesselManagement</em> should call the VesselManagement controller's Index action method. It did call as expected once in a while. But now it does not execute the action method. </p> <p>But if i type the Url as <em>hxxp://localhost:63363/Commercial/VesselManagement/index/abc</em> the Action method Index is called and the parameter abs is passed. </p> <p>Not only to this action method but to all action methods in the whole application the url has to be called with in this pattern. What could be the issue. Thank you all in advance for the help. </p> <h2><strong>Note:</strong> I have used hxxp insted of http</h2> <hr> <p>The Global.asx</p> <pre><code> protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes); //Configure FV to use StructureMap var factory = new StructureMapValidatorFactory(); //Tell MVC to use FV for validation ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(factory)); DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false; } } </code></pre> <hr> <p>The VesselManagement Index() Action </p> <pre><code>public ActionResult Index() { InitialData(); return View(); } </code></pre> <p><strong>NOTE:</strong> Just now i noticed that index does not take any parameters but i know that wouldn'd effect the routing. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload