Query string request too long in MVC

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.