Getting an ASP.MVC2/VS2010 application to work in IIS 7.5

安稳与你 提交于 2019-11-27 11:22:48

I've just had this problem, and unfortunately the fix here didn't work for me.

What did work was running this:

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

in a command window...works like a dream now!

(So, is ASP.Net not installed into IIS by default when you install VS2010?)

After more checking and trying I noticed in the "Turn Windows features on or off" dialog that "HTTP Errors" and "HTTP Redirection" were missing. This is strange because as far as I can remember this was installed automatically by the Microsoft Web Platform Installer. In any case "HTTP Redirection" seemed like a need-to-have feature when working with MVC. So after I installed it everything seemed to work perfectly.

Add this to your web.config file:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <!-- rest of config -->
</system.webServer>

It is such a pain doing this manually. But definitely doable! I managed it and summed it up in this step by step guide on adding an mvc 2 project to an exisitng web forms solution here. Hope this helps... it took me ages to work though all the config settings and there seem to be so few resources on the subject.

Please note that you must run aspnet_regiis.exe -ir as administrator, it seems obvious but when you are tired of trying things with no success to solve that, you could pass it.

Just to say a big THANK YOU to all the responses, after many hours trying different things, finally I could get work my MVC 2 app in IIS.

Vitaliy Ulantikov

What Helped to me is using classic pipeline for AppPool instead of integrated:

I was building an MVC2 application on my laptop Windows 7, using .net beta 2 and VS 2010 beta 2. When I installed the entire development environment on Windows Server 2008, including VS, built the solution and ran it, the routing worked fine.

The next step was to create a production server on Windows Server 2008, on which I deployed the .net 4.0 beta but none of the other stuff which came with the VS 2010 beta download. Under this configuration the routing never worked until I enable HTTP Redirection as indicated by Jeroen.

Hope this helps someone who might be in the same boat.

fordareh

Just wanted to note that I was having the same problem with 403 and 404s but adding the system.webServer and all the elements from the system.web/pages/namespaces node resolved it for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!