IISExpress VS.Net 2015 - HTTP Error 500.22 - An AS

2019-04-16 02:46发布

问题:

I've an ASP.NET MVC5 web app on my local Win 10 machine. Recently, I upgraded some Nuget packages and MVC4 to MVC5. And updated the target framework version to .Net v4.5.

Now, when I debug the web app from local VS.Net 2015 Community version I get the following error -

HTTP Error 500.22 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

Most threads I found were for IIS I'm talking about IISExpress. They suggested to change the web app's App Pool to a Classic in IIS (Post1, Post2, Post3). But VS.Net uses IISExpress so I went deeper into that as well and located - C:\Users\\Documents\IISExpress\config\applicationhost.config. Tried to edit it but it would allow me to configure only one WebSite1 which is localhost:8080 and mine runs as localhost:1960.

I've also tried the appcmd commandline approach but unless I've a website 'localhost:1960' there seems no way. I also sought an IISExpress UI tool Jexus but my 'localhost:1960' website is not listed.

Apparently, setting

<validation validateIntegratedModeConfiguration="false" /> in web.config

fixes it. But its not the best solution. And I can't remove httpHandlers or modules from my web.config.

I need to know how to manipulate the IISExpress that is invoked by VS.Net 2015 while debugging. Not IIS.

Thank you.

回答1:

Finally, I'm able to crack it for VS.Net 2015 and its configuration of IISExpress. ITs not possible to configure it 'externally' and nothing will work if you keep modifying IIS or IISExpress settings outside VS.Net.

It took me a while to narrow down my focus to VS.Net proj properties and configurations. I found that VS.Net created its own version of "applicationhost.config" which can be found at -

<myProject.sln path> \.vs\config\applicationhost.config

This is the file in which I had to change the application pool (applicationPool="Clr4ClassicAppPool) -

    <sites>
        <site name="WebSite1" ... ignore this sction if present
        </site>
        <site name="myProject" id="2">
            <application path="/" applicationPool="Clr4ClassicAppPool">
                <virtualDirectory path="/" physicalPath="D:\Source\myProject" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:1960:localhost" />
            </bindings>
        </site>

You just need to change the applicationPool (your Classic App pool name might be diff in that case get the correct one from in the same file). Also make sure you're updating the correct "site" node (the correct localhost url of your web app when debugged from VS.Net)

If still there's an issue set the following -

<applicationDefaults applicationPool="Clr4IntegratedAppPool" />

If still there's an issue, make the above mentioned changes in this file as well -

C:\Users\<youruser>\Documents\IISExpress\config\applicationhost.config

Might need restart as well. Hope this helps.



回答2:

I'll make a clean and simple answer for IIS express. And its working on 2018.

1) Go to your main solution directory which .sln file stands.

2) Navigate and open:

\.vs\config\applicationhost.config

3) Find your project name

<site name="Your.Project.ServiceName" id="2">

4) Change application pool from Clr4IntegratedAppPool -> Clr4ClassicAppPool

<application path="/" applicationPool="Clr4ClassicAppPool">

5) Restart your visual studio.

6) Enjoy!