Getting HTTP Error remotely instead of 'Connection was reset message' - asp.net

On an ASP.NET Web Application I have an upload file functionality. I'm restricting the file size up to 10 MB by configuring the inside web.config the maxAllowedContentLength attribute. (I'm using IIs 7.0 BTW).
It get the desired HTTP Error when I access the application from the local machine:
HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds the request content length.
When I access the application from another machine I get
The connection was reset
The connection to the server was reset while the page was loading.
How can I get a more descriptive error when my application is accessed remotely?
Thanks,
Maria.

Just ran into this myself. I got the "connection to server reset error" when trying to upload a 40 MB file after setting the maxRequestLength to 50384. I did not get the 404.13 error that is commonly referenced for the issue.
In addition to the httpRuntime web.config setting IIS 7 has a default request filtering limit of 30 MB that can be overridden. Below is my example for how to edit your web.config to allow uploading 50 MB files on IIS 7:
<system.web>
<httpRuntime requestValidationMode="2.0" enableVersionHeader="false" useFullyQualifiedRedirectUrl="true" maxRequestLength="50384" executionTimeout="3600" requestLengthDiskThreshold="1200"/>
...
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true">
<requestLimits maxAllowedContentLength="60000000"></requestLimits>
...

Hey I was having a the same problem. I put in both of these attributes and it worked for me. If someone has an explanation that would be awesome.
<httpRuntime maxRequestLength="102400" executionTimeout="3600" />
http://msdn.microsoft.com/en-us/library/e1f13641(VS.71).aspx
Regards,
Kieran

Related

IIS 8.5: Detailed errors for remote calls

I have a ASP.Net 5.2.3 WebAPI application running on a Windows Server 2012R2 with IIS 8.5.
When I make a local request that causes exceptions in the ASP.Net code, I get a nice, complete error message with stack traces. When I send the same request from another host, I only get a HTTP500 with body { "Message": "An error has occurred." }. I think this is the default behavior.
Now I want to enable these detailed error messages for remote requests, too. I searched around for a few hours already, and found these measures:
Edit Web.config
<system.web>
<customErrors mode="Off" />
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed" existingResponse="PassThrough" />
</system.webServer>
Enable 'Send errors to browser' in IIS Mangaer (IIS->ASP)
as described here: https://serverfault.com/questions/670853/iis-8-show-classic-asp-errors-in-browser
Enable "Detailed" IIS Error Page settings in IIS Manager (IIS->Error pages->500)
as described here: https://blogs.msdn.microsoft.com/rakkimk/2007/05/25/iis7-how-to-enable-the-detailed-error-messages-for-the-website-while-browsed-from-for-the-client-browsers
None of which seems to work, so I'm out of ideas by now.
Maybe it has to do with that my ASP.Net application is hosted in an existing IIS Site. I checked that the above modifications (step 2 & 3) are correctly applied on each level.
Give this a try...
To set the error policy in the application, modify the global Web API configuration:
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy
= IncludeErrorDetailPolicy.Always;
https://lostechies.com/jimmybogard/2012/04/18/custom-errors-and-error-detail-policy-in-asp-net-web-api/

HTTP Error 404.7 - Is there any other option to solve it?

I've started learning web services with ASP.NET. When doing a quick search on how to build and use a simple web service, this page seemed nice and simple.
I followed the instruction "copy FirstService.asmx in the IIS virtual directory...[and] open the web service" (actually, it is displayed as FirstService.asmx.cs), but from there on problems started. I got several HTTP Error (as explained here, I gave permissions to both IUSR and IIS_USRS, though the latter is probably irrelevant) and I'm now stuck with Error 404.7.
I tried the suggestions of these two (1, 2) SO posts (so I now have a second file on my folder, a Web.config file, though the site linked above said nothing about Web.config files), nothing helped.
Note that I also followed this page to register the correct version of ASP.NET with IIS.
Is there any other option?
EDIT:
Windows 7 Ultimate (64-bit), IIS 7.5
Full error (pardon the graphics):
Error Summary
HTTP Error 404.7 - Not Found The request filtering
module is configured to deny the file extension.
Detailed Error Information
Module: RequestFilteringModule
Notification: BeginRequest
Handler: StaticFile
Error Code: 0x00000000
Requested URL: http://localhost:80/MyWebServices/WebService1.asmx.cs
Physical Path: C:\Users\home\Desktop\MyWebServices\WebService1.asmx.cs
Logon Method: Not yet determined
Logon User: Not yet determined
My Web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<fileExtensions allowUnlisted="true">
<remove fileExtension="." />
<add fileExtension="." allowed="true" />
</fileExtensions>
</requestFiltering>
</security>
</system.webServer>
</configuration>
.cs is a code file and by default all .cs files are not allowed to be browsed in browser of course due to security concerns as all code is in there.
Also if you want to browse your webservice you don't need to browse .cs file you need to browse following
http://localhost:80/MyWebServices/WebService1.asmx
If MIME Type for asmx is not added you will need to added MIME Type for asmx.
Go to IIS
Select Your Website/Webservice on left side.
Select MIME Types.
Select Add on top right.
Add .asmx in File Name extension and text/xml in MIME Tpe

Maximum request length exceeded exception, maxContentLength not working

I know that this problem has a solution in stackoverflow, but it didn't work for me. I will be more specific below:
I had typical Maximum request length exceeded exception:
HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds the request content length.
That's my changes to web.config, under system.web:
<httpRuntime maxRequestLength="200000" executionTimeout="300" />
and under system.webServer:
<security>
<requestFiltering allowDoubleEscaping="false">
<requestLimits maxAllowedContentLength="200000000" />
</requestFiltering>
</security>
I also made this changes in applicationHost.
On one machine these worked like charm. That was windows 7 + iis 7.5. But on another with windows server 2008 + iis 7.0 I cannot get upload of 19 MB to work. I really dont know what to do now. Please help anyone.
OK. That machine was client's machine. Apparently he changed something in IIS manager regarding one of the site's subfolders and IIS manager created web.config in subfolder that was overriding my setting in parent.

asp.net - post file gives 404 page result even though posted file is well under maxRequestLength

I have a page on my ASP.NET site which uploads files.
I have attempted to tweak the web.config file to allow for larger uploads.
In my web.config, I set:
<httpRuntime maxRequestLength="2097152" executionTimeout="3600" />
On my page, when I attempt to upload smaller files, no issue...even at 25MB.
However, when I attempt to upload a 50MB file, I still get a 404 error page.
NOTE: I have a flash control on a different page which can upload almost 2gb with no issues, using this same web.config setting.
Same result on different PCs, same result when posted to different web servers.
My web server is Windows Server 2008 R2.
Any ideas of the cause? Why would flash be ok, but plain jane upload control have this problem?
I found the answer. Windows Server 2008 R2 is using IIS7 (of course), and in IIS7, you have to set the following in your web.config file (in my example to increase the limit to 2gb):
<system.webserver>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
<system.webserver>
This worked, when everything else didn't. IIS7 by default limits uploads to 30mb unless this override is set.
The executionTimeout applies only if the debug attribute in the compilation element is False. (see also http://msdn.microsoft.com/en-us/library/e1f13641.aspx)
So try it when starting your application in Release config.

Posting data to a HttpHandler greater then ~29MB gives a 404 error

I am testing a HttpHandler that accepts XML. It works fine when a small amount of data is posted but if I post data larger then approx 29mb, I get a asp.net 404 Error.
I am posting to the handler from another handler in the same project and I have tried 2 methods -
1. HttpWebRequest with "POST"
2. WebClient with UploadFile() and UploadData()
I get the same 404 error when the posted data is above 28.6 MB.
I also tried putting a breakpoint right in the beginning of the receiving handler and debugging. It is never hit. Appears like the handler was never called. Works ok for smaller sized data.
I already have the following setting. What am I doing Wrong?
<httpRuntime maxRequestLength="1048576" />
EDIT: I have also tried posting to a different handler that doesnt not consume posted data, just to test, but the results are the same.
Environment: Win 7, IIS 7.5, .net 3.5, VS 2008
alt text http://img401.imageshack.us/img401/4099/errormr.png
I discovered that the problem is with IIS 7 and above. It requires the max request length to be set in a different place.
See the following links -
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_22943810.html
http://msdn.microsoft.com/en-us/library/ms689462%28VS.90%29.aspx
The default value is 30000000. which is 28.6mb. The correct way to set in web.config is -
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824"></requestLimits>
</requestFiltering>
</security>
</system.webServer>
This config cleared the error I was getting. I wish the errors reported were more descriptive, at least on local machines
Does this mean that setting <httpRuntime maxRequestLength="1048576" /> is enough for IIS 6 ? (the live server is win2003)
Try to add this section to the web.config file:
<location path="YourHandler.aspx">
<system.web>
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
</system.web>
</location>
assuming you handler path is YourHandler.aspx.

Resources