简体   繁体   中英

Ajax POST 302 : Variable more than 1MB giving 302 redirect by Controller

Need to send updated html from front end side to my spring mvc controller . if i have the file size more than 1MB the contrller throwing me back 302 redirect for ajax call .

Below code contains following issue :

var allHtmlContent = document.getElementById('#iframeId').contentDocument.body.innerHTML;
    $.ajax({
        url : context + "/someControllerMethod",
        cache : false,
        type : 'POST',
        data : {
            htmlText : encodeURIComponent(allHtmlContent)
        },
        dataType : "text",
        success : function(b) {

        },
        error: function() {
           }
    }); 

here allHtmlContent variable contains all the of the HTML inside iFrame. if that iFrame loaded by file which is more than 1mb size i am getting 302 redirect by contrller so ajax is displaying that error in browser network.

is there any way to resolve this issue so that i can POST variable size more than 1mb .

Thanks in Advance

在nginx.conf文件中,将client_max_body_size设置为20MB(您的选择),这意味着当我们执行AJAX时,请求对象可以容纳大量数据。

I think this issue is related to maximum size of a request.

You can try below code into your web.config to set the maximum size of the request.

<system.webServer>
<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="1000000" />
    </requestFiltering>
</security>

The <requestLimits> element specifies limits on HTTP requests that are processed by the Web server. These limits include the maximum size of a request

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM