记录常见MVC 配置项,后续会不断更新。
1. IIS增加FileExtendsion(mime map) 和 maxAllowedContentLength
在 system.webServer 节点中增加 staticContent,
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
<remove fileExtension=".wasm" />
<remove fileExtension=".mem" />
<remove fileExtension=".json" />
<remove fileExtension=".appcache" />
<mimeMap fileExtension=".wasm" mimeType="application/javascript" />
<mimeMap fileExtension=".mem" mimeType="application/javascript" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".appcache" mimeType="application/javascript" />
</staticContent>
<!--Add maxAllowedContentLength-->
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="102400000" />
</requestFiltering>
</security>
</system.webServer>
1.1 Message 1:
Application information:
Application domain: /LM/W3SVC/1/ROOT/<App Domain>
Trust level: Medium
Application Virtual Path: <VDIR Path>
Application Path: <App Path>
Machine name: <Machine Name>
Process information:
Process ID: 0001
Process name: w3wp.exe
Account name: IIS APPPOOL\DefaultAppPool
Exception information:
Exception type: HttpException
Exception message: The URL-encoded form data is not valid.
at System.Web.HttpRequest.FillInFormCollection()
at System.Web.HttpRequest.get_Form()
at System.Web.HttpRequest.get_HasForm()
at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)
at System.Web.UI.Page.DeterminePostBackMode()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
1.2 Message 2:
Application information:
Application domain: /LM/W3SVC/1/ROOT/<App Domain>
Trust level: Medium
Application Virtual Path: <VDIR Path>
Application Path: <App Path>
Machine name: <Machine Name>
Process information:
Process ID: 0001
Process name: w3wp.exe
Account name: IIS APPPOOL\DefaultAppPool
Exception information:
Exception type: InvalidOperationException
Exception message: Operation is not valid due to the current state of the object.
at System.Web.HttpRequest.FillInFilesCollection()
at System.Web.HttpRequest.get_Files()
at FileUpload.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint
1.3 Message 3:
Application information:
Application domain: /LM/W3SVC/1/ROOT/<App Domain>
Trust level: Medium
Application Virtual Path: <VDIR Path>
Application Path: <App Path>
Machine name: <Machine Name>
Process information:
Process ID: 0001
Process name: w3wp.exe
Account name: IIS APPPOOL\DefaultAppPool
Exception information:
Exception type: InvalidOperationException
Exception message: Operation is not valid due to the current state of the object.
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeDictionary(Int32 depth)
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.DeserializeInternal(Int32 depth)
at System.Web.Script.Serialization.JavaScriptObjectDeserializer.BasicDeserialize(String input, Int32 depthLimit, JavaScriptSerializer serializer)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
at System.Web.Script.Serialization.JavaScriptSerializer.DeserializeObject(String input)
at Failing.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Resolution:解决方案
- Message 1 and Message 2
<configuration>
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="1000" />
</appSettings>
</configuration>
- Message 3
<configuration>
<appSettings>
<add key="aspnet:MaxJsonDeserializerMembers" value="1000" />
</appSettings>
</configuration>