What is the best way to get hosting of an ASP.NET MVC application to work on IIS 5 (6 or 7). When I tried to publish my ASP.NET MVC application, all I seemed to get is 404 errors. I've done a bit of googleing and have found a couple of solutions, but neither seem super elegant, and I worry if they will be unusable once I come to use a shared hosting environment for the application.
Solution 1
- Right-click your application virtual directory on inetmgr.exe.
- Properties->Virtual Directory Tab-> Configuration.
- Add a new mapping extension. The extension should be .*, which will be mapped to the Executable C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll, or the appropriate location on your computer (you can simply copy this from the mapping for .aspx files). On the mapping uncheck "check that file exists".
- 3 X OK and you're good to go.
- If you want, you can apply this setting to all your web sites. In step1, click on the "Default Web Site" node instead of your own virtual directory, and in step 2 go to the "Home Directory" tab. The rest is the same.
It seems a tad hacky to route everything through ASP.NET.
Solutions 2
Edit the MVC routing to contain .mvc in the URL and then follow the steps in solution 1 based around this extension. Edit: The original image link was lost, but here it is from Google's Cache:
Is the framework outdated? ASP.NET MVC is no longer in active development. The last version update was in November 2018. Despite this, a lot of projects are using ASP.NET MVC for web solution development.
It all depends on the version of Internet Information Services (IIS) and the request processing mode for your application. Here's a summary of the different versions of IIS: IIS 7.0 (integrated mode) - No special configuration necessary to use ASP.NET Routing.
The main difference between ASP.NET Core and ASP.NET MVC 5 is their cross-platform approach. ASP.NET Core can be used on Windows, Mac, or Linux, whereas ASP.NET MVC 5 can only be used for applications on Windows.
Answer is here
If *.mvc extension is not registered to the hosting , it will give 404 exception. The working way of hosting MVC apps in that case is to modify global.asax routing caluse in the following way.
routes.Add(new Route("{controller}.mvc.aspx/{action}", new MvcRouteHandler()) { Defaults = new RouteValueDictionary (new{ controller = "YourController"} ) });
In this way all your controller request will end up in *.mvc.aspx, which is recognized by your hosting. And as the MVC dlls are copied into your local bin , no special setttings need to be done for it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With