Why am I getting error 500.0 in when using IIS Exp

2019-06-15 08:20发布

问题:

I created a blank MVC 3 application on VS2010 SP1, and set the app to use IIS Express. When I debug, I get error 500.0 (0x80070585)

I am able to succesfuly run the app using the VS dev server

I have set the app directory to Full Permissions for Everyone, just to eliminate all possibility of security issues. I have further verified that IIS express is able to hit the web.config by confirming it using SysInternals ProcMon. ProcMon does not show the IISExpress process attempting to read from any other files in my application directory.

I have followed the suggestions in the following question, but it does not give me any better information. HTTP 500 Internal Error - IIS websites

No logs are generated in the IISExpress directory in either the Logs or TraceLogs directory, but a log is created in Temp, however it is not very useful.

Successfully registered URL "http://localhost:62017/" for site "MvcApplication1" application "/"
Registration completed for site "MvcApplication1"
Request ended: http://localhost:62017/ with HTTP status 500.0
Request ended: http://localhost:62017/ with HTTP status 500.0
Request ended: http://localhost:62017/ with HTTP status 500.0

There are no messages I am able to find in the Event Viewer

**Updates : ** Disabled firewall, no change Ran IISExpress via command line, no change

回答1:

I had the same issue last week, the app running perfect in dev web server from VS Studio. But in IISExpress anytime HTTP Error 500. My solution on this time was:

  • close VS Studio - solution set with IISExpress
  • got to: /Document/IISExpress/config/ in your profile
  • rename or delete applicationhost.config
  • open your solution in VS Studio
  • a Dialog will fire up from IISExpress - this will set a fresh config.
  • try to run your web app


回答2:

You may have some mime code in the Web.Config file like this:

<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />

if so, you should remove mimeMap before adding like this:

.
..
...
....
  </system.web>
  <system.webServer>
    <staticContent>
      <remove fileExtension=".svg" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    </staticContent>
  </system.webServer>

....
...
..
.


回答3:

reinstalling iis express appears to have resolved this problem



回答4:

This may be related to a conflict between the IIS Express applicationhost.config and your web.config.

A mimeType was added to my local web.config that was already present in the applicationhost.config and IIS Express started serving many 500 errors.

You may also notice this error in your Windows Event Log, "The directory specified for caching compressed content is invalid. Static compression is being disabled."

More info: http://blog.degree.no/2013/04/the-directory-specified-for-caching-compressed-content-is-invalid-static-compression-is-being-disabled/

I removed the mimeTypes from the web.config and the issue was resolved.

applicationhost.config location: C:\Users\[User]\Documents\IISExpress\config



回答5:

Are you using any PLINQ(.AsParallel) or Parallel.For or similar methods? I've found that the AggregateExceptions they throw aren't handled well by MVC (In my case, I got a blank 500 page and nothing in Logs/Event logs).

I identified the problem by paying attention to the "First Chance" exceptions which are logged in the Debug output window in VS. Try running the site, waiting for it to error, clearing the Debug window and the reloading the page. Do you see anything useful?



回答6:

There might be a problem with your config files, specifically web.config and applicationhost.config.

The only way I know how to diagnose this, is to publish a build to regular IIS, and in IIS Manager check the "Error Pages" module of the Site. If it is indeed an issue with those config files, you'll get a popup here with something along the lines: "Cannot add duplicate entry of type …". Google accordingly.
If the "duplicate entry" is of type "error", you can try adding the following element below httpErrors:

<remove statusCode="404"/>

That is, assuming you have an Error element below the HttpErrors with statusCode 404. (I had once.)