IIS offers .svc file for download instead of executing it on the server!
My RESTful WCF Web service appears to break itself if I leave it alone for a while! I can leave my PC with everything working and when I return and test the service with a simple url request it'll offer me the .svc file for download instead of initiating the request on the server!
This WCF service sits in it's own IIS Application folder under the root. I can get the service going again by opening up the IIS sub-folder in Visual Studio, deleting the web.config file and then adding it in again.
My first thought was that HTTP handler mappings for .svc have been borked so I re-ran ServiceModelReg.exe -i, but that hasn't resolved the issue.
Looking at the Handler Mappings for this IIS Application they appear correct and are inherited from the the web root. It's worth mentioning that this site 开发者_开发百科also has another Application folder running WCF services from a .svc fle and is still functioning fine!
Now that I've checked the obvious am a bit flumoxed about where to look next! Hoping someone has suggestions...
Are you running IIS6 or IIS7? And what .NET-version?
IIS6: http://blog.stevensanderson.com/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/
IIS7: Test this: "%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r -y
Do you really need .svc-extension in the rest url?
This might solve the problem: http://west-wind.com/weblog/posts/570695.aspx
Try
Go to programs and features, then turn windows features on or off.
Microsoft.net Framework 3.5.1.
Ensure both options are checked
Windows Communication Foundation HTTP Activation
Windows Communication Foundation Non HTTP Activation
Hope this helps.
Check out this article on getting your extension mapped correctly:
IIS Hosted Service Fails
EDIT: Are you hosting the service in your application? Maybe your app pool getting hung?
Well I did figure this out eventually. Just a weird quirk of IE/IIS. I was testing by putting my REST URI in IE's address bar and expecting to see a page of JSON if everything worked. This is what would happen the first time the service was used. On further attempts IE would offer to download a file called 'FooService.svc' that actually contained my JSON data - I was never being offered to download my server-side svc file.
Ho hum, computers eh. Can't live with 'em, ...
enable 32 bit run for connected app pool in IIS 7
It's resolved my problem.
精彩评论