How can I trigger IISExpress to respond to changes in applicationhost.config - iis-express

I've updated
%userprofile%\documents\iisexpress\config\applicationhost.config
per the changes on this post:
http://ben.onfabrik.com/posts/aspnet-web-api-compression
Namely, I've added
<httpCompression ...>
<dynamicTypes>
<add mimeType="application/json" enabled="true" >
to compress JSON in Web API responses. But judging by the content-length and content-type in the response header, IISExpress isn't compressing the response and therefore the config changes are not taking affect.
I also restarted IISExpress.
Any ideas? Thanks!

Running IISExpress.exe and entering 'Q' to stop IIS Express didn't do the the trick. But shutting down Visual Studio and then stopping IIS Express did. Upon relaunching the VS, JSON data was then compressed.

Related

"HTTP Error 403.14 - Forbidden" error when running the webapp

What is the reason for the error page I get when I run my webapp in Visual Studio. The URL is http://localhost:5000/
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
Reason: http://localhost:5000 refers to the root of the webserver. So, for the above request, it tries to read the root folder of the server. However, IIS (express) by default doesn't allow you to view the file system. Therefore it shows above error.
Most probably you don't need to access the root of the server, instead you might need to access your webapp (ex: http://localhost:5000/myapp).
However, if you know exactly what you are doing then you can enable IIS to show the root directory (file system) using the following config in the Web.config of your application
Important: Below config should not be activated in a production or any
publicly reachable environment which is obviously a high critical
security issue.
<system.webServer>
<directoryBrowse enabled="true" />
<modules runAllManagedModulesForAllRequests="true"></modules>
</system.webServer>
Two things are usually the issue when I get this error:
1st: I never defined a standard document and changed it at some point - therefore the standard document that is automatically defined by the IIS in this case, doesn't exist
2nd: I didn't enable index search
You might want to try this. You can change those settings in the IIS settings directly.

WCF not working when debugging in visual studio but works in IE

I have a WCF that is hosted in an ASP.NET application. Suddenly, the WCF service has stopped working when i debug it in visual studio 2010. When i try to access the service, it throws the below exception.
CommunicationException was unhandled by user code. The remote server returned an error: NotFound
I have WCF tracing enabled but no errors are being logged.
The strange bit is that if i deploy the code to my QA server and access the application, the service works fine, so the code looks like not the problem.
If i also get the source code currently running in production successfully & try debugging it in my dev environment, it fails with the same error i mention above.
Any one have an idea what could be messed up in my dev environment?. I have tried both IE, Firefox & Chrome & the results are the same.
I after a very long debugging involving deleting Bin & obj folders and lots of rebuilds, i finally got this WCF service working again.
First, i suspected the service could be corrupted somehow, so i tried to update the service reference in my silverlight application but was bumped with the following error.
There was an error downloading 'http://localhost/mySite/Webservice/GetData.svc'.
The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://localhost/mySite/Webservice/GetData.svc'.
The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.
I then browsed to the physical folder path to confirm if really my .svc file was there and indeed as expected, the file was there.
Trying to Browse to the path http://localhost/mySite/Webservice/GetData.svc in my browser bumped me with another error below.
HTTP Error 404.7 - Not Found The request filtering module is
configured to deny the file extension.
Most likely causes: Request filtering is configured for the Web server
and the file extension for this request is explicitly denied.
This made me start thinking that suddenly, IIS 7.0 has decided to block access to my .svc files.
I then added fileExtension=".svc" mimeType="application/octet-stream" to IIS, restart IIS but got the same error.
I then read on some blog i cant remember about adding <add fileExtension=".svc" allowed="true" /> under <requestFiltering> tag in file applicationHost.config located at C:\Windows\System32\inetsrv\Config, still nothing changed. Tried adding <mimeMap fileExtension=".svc" mimeType="application/octet-stream" /> under serverSideInclude in the same file, again with no luck.
Tried this http://www.adamwlewis.com/articles/iis-7-not-serving-files-4047-error still with no luck.
The following 2 steps are i think what resolved the issue.
I added a mapping for the SVC extension to ASP.NET by running ServiceModelReg.exe -i from C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation
Browsed to my .svc file in the browser and this time it looked like i had made some progress but still, i had one more error to overcome . The is bellow.
Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
I resolved the above error by registering the correct version of ASP.NET using the ASP.NET IIS Registration Tool (aspnet_regiis.exe,) as described in the link below
https://msdn.microsoft.com/en-us/library/hh169179(v=nav.70).aspx
At this point my service was back to normal as it had always been. I still haven't figured out what messed up my development machine.

How can I find out what causes AppCache Fatal Error on IE10?

I'm trying to create an HTML5 Application Cache for a very large (about 2 gigabytes) web app that will be used internally on a Windows 8 Professional tablet and IE10. Something is causing the caching process to fail, but the only debug information I can find is the F12 console, which simply states "AppCache Fatal Error".
I made an error handler and tried to debug:
if (window.applicationCache)
{
var oAppCache = window.applicationCache;
oAppCache.onerror = function(e) {
alert(e); // Outputs [object Event], I use this row as a breakpoint target
};
}
However, e contains no useful information when viewed with the debugger.
According to the web server logs, the last file requested before the error is a JPEG just like many others. Where should I start looking for clues about what is causing the error? The page caches fine on Firefox.
Bashed my head against the same issue for a while. I binary-chopped my manifest until I worked out which line was causing the error: it was the 1000th line of CACHE entries (not just the 1000th line of the manifest).
It seems there's a hard limit on the number of items you can have in a cache in IE10. I haven't found this documented anywhere after a few minutes searching, but I daresay someone more persistent might trawl it up.
I verified that it doesn't matter what the content of the 1000th CACHE item is; IE just prevents you outright from beginning the cache download. It might be a restriction for security reasons, stopping someone flooding the cache, or using it to DoS a site by injecting a manifest with thousands of entries into a page.
Perhaps try splitting your app into chunks (over subdomains?) with different caches. Might make for a better user experience if it's downloaded in chunks, you can always automate the "install" by redirecting between a series of smaller caches.
For the record: I had trouble with IE (10) giving me AppCache Fatal Error. It turns out IE requires the manifest to be served with the proper content-type, that is
Content-Type: text/cache-manifest
Chrome and Firefox aren't as picky.
In case it helps anyone, I've found another way to rectify this error.
If you are using the Application Cache and set the Cache-Control header for the html file with the cache.manifest entry to "Cache-Control: no-cache, no-store", you will receive this error. Removing the no-store flag for the Cache-Control header will fix the issue in this instance. I was trying to use the Application Cache for resources only and not for the html page itself, but unfortunately that's not what it was designed for.
Also note that all other browsers will just ignore the no-store flag for files in the cache.manifest, whereas IE is technically doing the right thing by being a little more pedantic.
Internet explorer Group Policy sets limitation of cache resource list size to 1000 items. This can be extended by changing this policy. More can be found here , part "Set maximum application cache resource list size".
My problem was, that IIS used the .manifest-Extension and set the Content-Type to x-ms-manifest. So I added the following into the web.config - this solved the fatal error (IE 11) and the appcache now works with HTTPS (SSL) which it didn't before (only worked with HTTP):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="."
inheritInChildApplications="false">
<system.webServer>
...
<staticContent>
<remove fileExtension=".manifest"/>
<mimeMap fileExtension=".manifest" mimeType="text/cache-manifest"/>
</staticContent>
...
</system.webServer>
</location>
</configuration>

Why am I getting error 500.0 in when using IIS Express (significant debug info included)

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
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
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>
....
...
..
.
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
reinstalling iis express appears to have resolved this problem
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?
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.)
In my case the issue was caused by using windows authentication + firefox + wrong domain login with insufficient permissions.
Details:
My dev machine is using windows domain "domA", the application will run in an environment accepting logins from domain "domA" and "domB". While on the webserver both will work, on my dev machine only my account in "domA" has sufficient permissions to access all files of the application. In IE "domA" is used by default while in FF I get a login dialog where I did login with my account from "domB".
Confusing issue I know, but maybe there is someone else having the same situation. At least it will help me the next time I run into it. :)
Just in case catches someone else out, I had similar error but the issue was I had updated my web.config and there was an extra ">" character where it should be.. so malformed web.config file can cause the same behaviour.

Turn IIS7 HTTP Error Handling Off?

I just got setup on my first Windows Server 2008 / IIS7.5 server for a contest I am participating in. I can't for the life of me figure out how to turn OFF error handling COMPLETELY. The only options I see are:
Custom
Detailed
Detailed Local, custom for remote
I want to turn the feature off completely, and I don't see any way to do that. Am I missing something?
My Situation:
I have a RESTful PHP framework that catches exceptions and emits an HTTP 500 status if the exception has not already been handled. It then puts the specified exception message in the response body and sends it to the browser. This works fine in Apache - the correct headers are sent and the message is displayed to the user. In IIS, however, the response for 4xx and 5xx HTTP status codes is always intercepted and injected with some other prepared message or HTML file, and that's exactly what I don't want it to do anymore. Please help!
After some more extensive searching, I found the answer here:
http://blogs.msdn.com/webdevelopertips/archive/2009/08/24/tip-93-did-you-know-php-and-custom-error-pages-configuration.aspx
The solution is to manually edit your web.config file with this custom "httpErrors" entry:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
However, due to IIS 7.0 "lockdown" feature you might get a "This configuration section cannot be used at this path. This happens when the section is locked at a parent level." error. To solve that, execute the following in the command prompt:
cd C:\Windows\System32\inetsrv
appcmd unlock config /section:httpErrors
In IIS Manager -> Site -> Error Pages, right-click each error page and choose ‘Remove’.
Unfortunately there is not a way to tell IIS not to interfere from the script side, so it's always an annoying deployment issue.

Resources