Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would suggest overriding of DefaultControllerFactory</p> <pre><code>&gt; public class CustomControllerFactory : DefaultControllerFactory &gt; { &gt; public override IController &gt; CreateController(System.Web.Routing.RequestContext &gt; requestContext, string controllerName) &gt; { &gt; try &gt; { &gt; return base.CreateController(requestContext, &gt; controllerName); &gt; } &gt; catch (Exception exception) &gt; { &gt; // collect route data &gt; string id = (string)requestContext.RouteData.Values["id"]; &gt; string action = (string)requestContext.RouteData.Values["action"]; &gt; // set full path as routing "page" parameter &gt; VirtualPathData path = requestContext.RouteData.Route.GetVirtualPath(requestContext, &gt; requestContext.RouteData.Values); &gt; requestContext.RouteData.Values["id"] &gt; = path.VirtualPath; // or anything you need &gt; // use controller page by default &gt; controllerName = "MyController"; &gt; // set basuc routing data &gt; requestContext.RouteData.Values["controller"] &gt; = controllerName; &gt; requestContext.RouteData.Values["action"] &gt; = "index"; &gt; // call base method to create controller &gt; return base.CreateController(requestContext, &gt; controllerName); &gt; } &gt; } &gt;} </code></pre> <p>And than just register this as default controller factory in global.asax.cs file</p> <pre><code>protected void Application_Start() { ControllerBuilder.Current.SetControllerFactory(new MyNameSpace.CustomControllerFactory ()); RegisterRoutes(RouteTable.Routes); // this already exists by default } </code></pre>
    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.
    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