Note that there are some explanatory texts on larger screens.

plurals
  1. POC# MVC 3 Root Route doesn't seem to work
    primarykey
    data
    text
    <p><strong>EDIT:</strong> Sorry I explained it badly. Basically, in the below example, I want "this-is-handled-by-content-controller" to be the "id", so I can grab it in ContentController as an action parameter, but I want to access it via the root of the site, e.g mysite.com/this-is-not-passed-to-homecontroller.</p> <p>I'm trying to create a root route that will go to a separate controller (instead of home).</p> <p>I've followed the "RootController" example posted somewhere else that implements IRouteConstraint but it just doesn't seem to work and I've already wasted a couple of hours on this!</p> <p>Basically, I have a LoginController, a HomeController, and a ContentController.</p> <p>I want to be able to view HomeController/Index by going to <a href="http://mysite/" rel="nofollow">http://mysite/</a>. I want to be able to view LoginController/Index by going to <a href="http://mysite/Login" rel="nofollow">http://mysite/Login</a>. But.. I want the ContentController/Index to be called if any other result occurs, e.g: http:/mysite/this-is-handled-by-content-controller</p> <p>Is there an elegant way to do this that works?</p> <p>This was my last attempt.. I've cut/pasted/copied/scratched my head so many times its a bit messy:</p> <pre><code>routes.MapRoute( "ContentPages", "{action}", new { Area = "", controller = "ContentPages", action = "View", id = UrlParameter.Optional }, new RootActionConstraint() ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { Area = "", controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults new string[] { "Website.Controllers" } ); </code></pre> <p>Any help is appreciated greatly!</p> <p>chem</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.
 

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