简体   繁体   English

Uri字符串太长-对于我的POST方法的输入参数

[英]The Uri string is too long - for the input parameter of my POST method

I use fiddler to call my method, and for small strings it works perfectly. 我使用提琴手来调用我的方法,对于小的字符串,它可以完美地工作。 However, my input parameter may be the content of a 250 MB file. 但是,我的输入参数可能是250 MB文件的内容。

Here's how I call it: 这是我的称呼:

POST

http://localhost:23234/api/myfiles

User-Agent: Fiddler
Host: localhost:23234
Content-Type: application/json
Content-Length: 317210

And in the Request Body part, I have the content of a file which has 5.000 lines. 在“请求正文”部分中,我具有5.000行的文件内容。

The method isn't getting hit. 该方法没有受到打击。 Instead, I get error 500, and the error messsage is: The Uri string is too long. 相反,我收到错误500,错误消息为:Uri字符串太长。

What can I do to make this work? 我该怎么做才能使这项工作?

If you are hosting your API in IIS you should increase the maximum allowed request size (which by default is 4MB) by adding the following to your web.config: 如果要在IIS中托管API,则应通过将以下内容添加到web.config中来增加允许的最大请求大小(默认为4MB):

<system.web>
    <!-- The value is in KB -->
    <httpRuntime maxRequestLength="1048576" />
</system.web>

and if you are using Integrated pipeline mode: 并且如果您使用集成管道模式:

<system.webServer>
    <security>
        <requestFiltering>                          
            <!-- The value is in bytes -->
            <requestLimits maxAllowedContentLength="1073741824" />
        </requestFiltering>
    </security>
</system.webServer>

This will allow requests of 1GB to be sent. 这将允许发送1GB的请求。

Also you seem to have set the Content-Type to application/json so you should make sure that you are POSTing a valid JSON payload. 另外,您似乎已将Content-Type设置为application/json因此应确保您正在发布有效的JSON有效负载。 Last but not least, ensure that you have selected POST in the Fiddler combobox with the verbs (the default is GET). 最后但并非最不重要的一点是,确保已在Fiddler组合框中选择了带有动词的POST(默认为GET)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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