Recently in MVC to do export Excel function, through the page to the field ID and the corresponding Chinese name through a tag to the controller process, always error.
1. First time error
Specific solutions:
You can configure the IIS server to reject requests that have a query string that is longer than the specified value. This error is returned if the requested query string is larger than the configured value. If you need to increase the allowable length of the query string, modify the configuration/system.webserver/security/requestfiltering/[email protected] setting.
Confirm the configuration/system.webserver/security/requestfiltering/in the ApplicationHost.config or Web. config file[email Protected] settings.
Workaround One:
In the project's Web. config, add the following configuration under the,<system.webserver> path:
< Security > < requestfiltering > < maxquerystring= "4080"/> </ Requestfiltering> </security>
In fact, the change: maxquerystring value, the default size is 2048
Workaround Two:
For all projects to apply this configuration, find the ApplicationHost.config file in C:\Windows\System32\inetsrv\config , in,< Add the following configuration under the System.webserver> path: Add the following configuration:
< Security > < requestfiltering > < maxquerystring= "4080"/> </ Requestfiltering> </security>
For already set, you can modify the size of the maxquerystring.
However, through the above changes are still unresolved, error:
Workaround:
This is because the parameter length in the site URL exceeds the maximum possible length of the query string in the HTTP request, which can be resolved by setting the Httpruntimesection.maxquerystringlength property of the configuration file.
Open the Web. config in the project, set the Maxquerystringlength property of the HttpRuntime node under the <system.web> node, and the settings in Web. config are as follows:
< system.web > < maxquerystringlength= "9999"/></system.web >
The default value for the maximum length of the query string is 2048, which we can set according to the requirements, but if the parameters are too long it is best to use the POST request, too long querystring for the URL.
With the above changes, the problem has been resolved.
Reference:
Https://www.afuhao.com/article_articleId-99.shtml
http://shiyousan.com/post/635717961342698849
Query string request too long in MVC