I've been fighting with this for several hours with no headway.
I am trying to publish a web app (MVC3, .net4, made in Visual Studio 2010) to a server. All googles eventually lead to this article, which has not been helpful. According to it, MVC3 running on IIS 6 (MVC and .net4 are installed, it is a 2k3 server) should just work. Different set ups give me different issues, but nothing that works. With default settings, I get "Directory Listing Denied This Virtual Directory does not allow contents to be listed." If I turn on directory browsing I can see the directoy of the site, but this isn't useful.
In IIS there is an option to use the default page, but I thought that MVC didn't use one. There was no "default.aspx" in my project when I started it, and it has been working fine through the debug testing local server. If I need a default page, I don't know how to make one. If I don't need one, what settings do I need to use in IIS 6 to get it to serve the pages properly (using the mvc module?).
This is my first web app, so I am probably missing something basic. It's entirely possible I deleted some critical file from the project.
Edit: not sure if it makes a difference, but the site is not being published to the root of the domain. The URL ends up being www.company.net/directory.
Edit: I tried making a new MVC3 app in visual studio, just the default one, and published it immediately to the server. Same error. Its definitely something in IIS.
Try this.
- Open IIS manager.
- List item
- Select your website then properties.
- Go to Virtual directory
- Click on Configuration
- On Application Configuration
Application extension - add .mvc extension and path C:\windows\microsoft.net\framework\v4.xxxxx\aspnet_isapi.dll - On the wildcard application maps insert same path as above
- UNCHECK verify that file exists (if you check it won't run)
Phil Haack has a good article: http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
I had the exact issue when moving from local development to a web server. For some reason, the server didn't have the proper mappings set up. Check the handler mappings configuration and make sure that all of the MVC related mappings are listed, e.g. ".cshtm" and ".cshtml" -- there should be several for each extension.
I had the same problem. Besides following all of the above steps, i also had to create a new website in IIS. All my production websites ran under the "Default Website". I had each application setup as a Virtual Directory. My "Default Website" runs ASP.NET 2.0. which is fine for all other applications. This doesn't work for MVC apps since it requires ASP.NET 4.0.
To solve the problem I did the following:
- Created a new application pool
- Created a new directory under inetpub and called it wwwroot4_0
- Moved my application to this location
- Created a new website and set the ASP.NET Version to 4.0.
- Under the new website, i gave it a different port, port 81
- Created the new application as a virtual directory under my new website
Changed the routs of my application to include the extension .aspx
routes.MapRoute( "Default", // Route name "{controller}.aspx/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults );
The way I would access the application is this: www.mydomainname.com:81/MyAppName/Default.aspx
Please let me know if this helps anybody. Thanks.
来源:https://stackoverflow.com/questions/6391804/mvc3-publishing-and-iis-6