Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I set up a route for the home page of an ASP.NET MVC site?
    primarykey
    data
    text
    <p>I'm working with an ASP.NET MVC site which will use a CMS controller for all pages of the site except for the home page. Here's the idea:</p> <p><strong>Home controller:</strong></p> <ul> <li>www.site.com</li> <li>www.site.com/default.aspx</li> </ul> <p><strong>CMS Controller:</strong></p> <ul> <li>www.site.com/about</li> <li>www.site.com/agenda/schedule</li> <li>www.site.com/monkey/eats/spaghetti</li> <li>(pretty much anything else)</li> </ul> <p><a href="http://www.58bits.com/blog/2008/09/29/ASPNetMVCAndRoutingDefaultaspx.aspx" rel="noreferrer">This page</a> lists some options on how to set up a default page routing:</p> <ol> <li>Leave Default.aspx unrouted and unredirected as the entry point to your application - with static links that take your users into the MVC portion of the app (or other static content). </li> <li>Redirect Default.aspx in the code behind, either using the Page_Load event handler code, or use Response.Redirect("~/home") to send them to the Home controller (although this is a round-trip redirect). </li> <li>Rename or delete Default.aspx. Despite the warning in the markup that says that default.aspx is required to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request... it's not actually needed in either the VS dev server, or IIS7. The default request will remain an application root request "/" and will be caught by the default route and sent to the home controller.</li> </ol> <p>I guess one other option is to just use one controller with some logic that detects the home page case, but that seems to be fighting the concept.</p> <p>How do you recommend setting up a specific route for the site home page?</p>
    singulars
    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