Asp.Net Core RC2 timeout on upload - asp.net-core-mvc

Working on file upload with somewhat large payload (800 MB) and server is timing out.
Using asp.net core RC2, mvc6 and Kestrel server on Windows (7 and 10) and cannot find where to set the session timeout.
I'm going nuts that I can't find it searching the web. How do you set the timeout?

I just ran into a similar problem and found out that apparently IISExpress (at least when used from Visual Studio) has a default 2 minute connection timeout after which it responds with 502 bad gateway. I could fix the problem by adding the attribute "connectionTimeout" with a suitable value to the element "webLimits" in .vs\config\applicationhost.config:
<webLimits connectionTimeout="00:10:00" />
Here is some more info on the webLimits element: https://www.iis.net/configreference/system.applicationhost/weblimits
Update after upgrading to ASP.NET Core 1.0: There is a "requestTimeout" attribute on the aspNetCore element in the web.config. This attribute also has a default value of 2 minutes.
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore
processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
forwardWindowsAuthToken="false"
stdoutLogEnabled="false"
requestTimeout="00:10:00" /> <!-- <== -->
</system.webServer>
</configuration>
For more attributes on aspNetCore see:
https://learn.microsoft.com/en-us/aspnet/core/hosting/aspnet-core-module

Related

.Net Core 2.1 Error 413 on multipart/form-data POST only on IIS not IIS Express

I'm hitting a problem with multipart/form-data POST uploads on IIS. My client is an Angular SPA and my backend is on .Net Core 2.1 (I know it's old).
The backend project is published as Self-Contained win-x64. I'm not sure how it's configured exactly on IIS / Kestrel but the IIS App runs under a specific Application Pool (No managed Code / Integrated). My web.config looks like this:
<configuration>
<location path="." inheritInChildApplications="false">
<system.web>
<httpRuntime maxRequestLength="1048576" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\my.app.exe" stdoutLogEnabled="false" stdoutLogFile=".\log\path" />
</system.webServer>
</location>
</configuration>
In my development environment instead I'm using IIS Expres.
Now I added a multipart/form-data upload, sending form data together with a blob/image. This worked out of the box in development settings. However when I publish to staging environment with real IIS and the above web.config, I always get 413 Request entity too large.
My controller looks like this:
[HttpPost]
[DisableRequestSizeLimit]
[RequestFormLimits(MultipartBodyLengthLimit = int.MaxValue, ValueLengthLimit = int.MaxValue)]
[RequestSizeLimit(int.MaxValue)]
[Route("my/route")]
public ActionResult MyHandler()
I also added limits for Kestrel in Program.cs:
.UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = 104857600; // 100MB
}
)
And to make the weirdness complete the 413 in staging environment only happens in Firefox. I have no idea what else I can do. I also cleared cache in firefox.
After longer search I finally found the necessary setting in IIS to make this work in Firefox. And it has indeed be mentioned in a few sources as the 'last option'. For me it was necessary in this case.
In 'IIS Manager' I selected the backend application and opened 'Configuration Editor'
system.webServer/serverRuntime -> uploadReadAheadSize=2147483647
That maked it work.

Ajax post request have more than 4 mb file

I am developing an MVC 4 application.I am sending ajax post request to a controller action.When the post data is more than 4MB the requist to action is failing.What is the solution for this?
You need to change two configuration parameters (value is in KB)
In Web.Config
<configuration>
<system.web>
<httpRuntime maxRequestLength="8192" />
</system.web>
</configuration>
In IIS
Update your 'Maximum allowed content length' setting, as described here : http://ajaxuploader.com/large-file-upload-iis-asp-net.htm
You could try extending the size of one of these properties..
<system.web>
<httpRuntime maxRequestLength="x" />
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="x" ></requestLimits>
Set, x to the size limit you want. Read this post for help.

IIS caching and HTTP caching

What's the difference between
<caching enabled="true" enableKernelCache="true">
<profiles>
<add extension="*" location="Any" policy="CacheForTimePeriod" duration="00:30:00" varyByQueryString="*" varyByHeaders="Accept-Language" kernelCachePolicy="CacheUntilChange" />
</profiles>
</caching>
and
<httpProtocol>
<customHeaders>
<add name="Cache-Control" value="private, max-age=1800, must-revalidate" />
<add name="Pragma" value="private, max-age=1800, must-revalidate" />
<add name="Expires" value="1800" />
</customHeaders>
</httpProtocol>
If I understand well, the first is for IIS (cache file on server, to answer quickly) and the second one is for proxy/client (ask a new version every 30 minutes) ?
What do you think about my cache policies ? I want to improve performance but because I have important fresh information every 30min, I set to 30 min every cache...
The Pragma header is implementation specific and secondary to the Cache-Control header (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32). Better to not use it.
Setting the cache to "private" prevents caching on proxies, you might want to set it to "public" for faster client response--this change is especially recommended if your content is served over HTTP rather than HTTPS ("public" is ignored in that case, unless SSL is cracked within for instance a corporate fire-wall).

WebDAV and WebAPI together cause Error: Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

I have both WebDAV installed and running on my site, as a virtual sub site i have a MVC WebAPI site, the API works great, until I try to send a PUT request to it, then i get the below error:
HTTP Error 500.21 - Internal Server Error
Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
If I disable WebDAV, then everything works fine and I get no errors. This only happens when WebDAV is enabled.
I have all of the following code in my web.config:
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="false">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
I've tried messing with various app pools.
I've also tired all of the things mentioned in all of these questions:
How to get rid of this error Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list
Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
How to fix: Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list
None of this has solved my issue, is there anything else out there that I have not tried?
We ended up going to Microsoft with this, they reviewed it for several weeks before coming back saying that it's not possible to run WebDAV and WebAPI in the same site.
They will try to address this issue in a future release of IIS.
#jblaske has a good response.
If you want to remove it temporarily then maybe this article is the best solution.
If you want to remove the handler all together then follow these steps.
Open IIS and go to the site in question.
Click on "Handler Mappings"
Find the handler named "WebDAV"
Select it and Remove it
This is my original post.
I started getting this error after I removed WebDAV module and handler manually from IIS to get PUT working. I had to remove "WebDAV Publishing" server role to get over this error. After removing this role and restarting the IIS, PUT is working fine.
You might have a typo issue in the declaration of handlers. Thomas Marquardt's Blog says
5.0 Troubleshooting
If you receive an error similar to the one below, your
section is probably invalid.
HTTP Error 500.21 - Internal Server Error Handler "" has
a bad module "ManagedPipelineHandler" in its module list You probably
have a handler mapping that does not have the correct precondition.
IIS is not forgiving in regard to typos, and preconditions are
case-sensitive. The text must be preCondition=”integratedMode” or
preCondition=”classicMode”.
Also, another suggestion from the comments on that article:
Andrew Johnson 25 Jan 2011 3:20 AM #:
I found that I can also get the "Handler has a bad
module ManagedPipelineHandler in its module list" if the handler has
requireAccess="None". For me, changing this to requireAccess="Read"
made the error go away.
That comment might apply to your case as I see that in applicationHost.config the entry for WebDav handlers is (note the requredAccess="None"):
<add name="WebDAV" path="*" verb="PROPFIND,PROPPATCH,MKCOL,PUT,COPY,DELETE,MOVE,LOCK,UNLOCK" modules="WebDAVModule" resourceType="Unspecified" requireAccess="None" />
Found an alternate for this issue.
When the patches of the server were pushed,The default framework were set back to 2.0.
Re register .Net framework by going to framework 4.0 folder C:\Windows\Microsoft.NET\Framework64\v4.0.30319
Executing the command aspnet_regiis -I
Check the web.config to match the .Net framework version
Go to IIS -> Application pool, set the .Net framework values to 4.0
Restart the IIS.

Html.Telerik().StyleSheetRegistrar() output file generating 404 message on asset.axd

I'm using the Telerik controls form MVC and they work great in my work/home dev environments, and in the work prod environment, but when I tried to deploy to my home prod environment (IIS7) I get a problem.
I've added the axd mime type, but wan't sure what else to do.
I read a post suggesting adding a handler, but wasn't sure if I'm setting that wrong or I'm just looking in the wrong direciton.
if you're on IIS7 make sure you add the handler to the <system.webServer><handlers> section:
<add name="MyName" path="MyName.axd" verb="*" type="NameSpace.Class, Assembly" />
I added: <add name="ScriptRegistrar" path="Access.axd" verb="*" type="Telerik.Web.Mvc.UI.ScriptRegistrar, Version=v2.0.50727" />
http://localhost:1000/asset.axd?id=sQAAAB-LCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee--997o7nU4n99__P1xmZAFs9s5K2smeIYCqyB8_fnwfPyJ-8UfT9qNHH7X5u_butGk-Gn10SX_u7ezujHfH93Ye0gfTjx619TqnX2YfPbr36f3RR_Tze7_4oxU1PKmWbb5s775ur8scb5_zV9VHj3ZGHy2pwbRaLKrlGKB_yYi_2JUv2rzM6-LtuN9gL2xwWTRtJt9__5d8_5f8PwEAAP__qtxwmrEAAAA%3d
To enable web resource combining with the Telerik Extensions you need to register the WebAssetHttpHandler in your webconfig:
IIS 7
<add name="AssetHandler" preCondition="integratedMode" verb="GET,HEAD" path="asset.axd" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc"/>
IIS 6
<add verb="GET,HEAD" path="asset.axd" validate="false" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc"/>
This handler enables you to use the Combine, Compress, and Cache features of the Script and StyleSheet Registrars. You can learn more and see additional config details in the Telerik online docs:
http://www.telerik.com/help/aspnet-mvc/web-assets-working-with-javascript-web-assets.html

Resources