简体   繁体   中英

IIS 7.5 hosting mvc 3 razor app default page

I have a MVC 3 Razor app and I need to deploy it on http://www.mydomain.com .

The trouble is that that, when I hit http://www.mydomain.com it gives a 404 Error . I need http://www.mydomain.com/Home view loaded by default, I would like to avoid using a redirect method as it is not SEO friendly...

If you haven't chanegd the RegisterRoutes in the Global.asax.cs file, then it defaults to /Home/Index see below.

routes.MapRoute(
 "Default", // Route name
 "{controller}/{action}/{id}", // URL with parameters
 new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
 );

So the 4th line of code is where the defaults are configured.

As for the default setting, you can use the RegisterRoutes(RouteCollection routes) method that is available in Global.asax.cs to mark the default controller and its corresponding action method. Regarding hitting www.mydomain.com and getting a 404 error, I need more information. if you are on windows and working on a developer machine, did you add the entry to hosts file located in

C:\\Windows\\System32\\drivers\\etc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM