问题
I was getting this error:
404.17 - The requested content appears to be script and will not be served by the static file handler
I'm running IIS 8.5 on Windows 8, VS2013. My App pool is set to .NET 4 (I believe the move from .Net 2 to .Net 4 is what caused the problem). My service code is .NET 3.5.
I checked that .NET 3.5 and 4.5 are both enabled as features, along with Extensibility for both, ISAPI extensions and filters. I tried:
- Uninstalling and re-installing ASP.NET 4.5
- Running ServiceModelReg (as suggested here)
I then finally fixed it by enabling "HTTP Activation" (as suggested here).
My question is this: what does this error actually mean? I've basically fixed it by blindly searching the net and trying various suggestions, but it occurs to me that I might have been able to do this quicker if I understood exactly what this error was telling me.
EDIT:
After the helpful and constructive comments made on this post, I think I'll try to clarify exactly what I'm asking here.
Obviously, the error message in and of itself does make sense (to an extent). A static
handler would be unable to run a script
. So, is that what HTTP Activation does? Why would ServiceModelReg help? Why would this problem appear when moving from .Net2 to .Net4?
回答1:
The error message is telling you:
The static file handler is about to serve the source code of your server-side script instead of another handler executing it. That probably is not what you want to happen, so I'm throwing an exception instead.
This error is an indication of your handlers not being set up right. In your case the request to your service was supposed to be picked up by the Http Activation Service (I'm guessing an IHttpModule), but because it wasn't (the module was not active), it ended up being handled by the static file handler as a final fallback.
ServiceModelReg installs or re-installs the proper WCF components. Obviously that might work to fix this problem if you don't have WCF set up altogether.
The Http Activation Module (System.ServiceModel.Activation.HttpModule) is registered in the machine.config file. .NET 2.0 and .NET 4.0 have separate machine.configs. The Http Activation feature also exists for both .NET versions separately.
来源:https://stackoverflow.com/questions/25532110/what-causes-wcf-error-404-17-to-be-shown