简体   繁体   English

错误:413 “请求实体太大” Html + MVC WCF 服务

[英]Error: 413 “Request Entity Too Large” Html + MVC WCF service

Basically, I created one page into HTML then i want to send two files XML & SVG.基本上,我在 HTML 中创建了一页,然后我想发送两个文件 XML 和 SVG。 Both files are converted to text and then send to the WCF service in the MVC project.两个文件都转换为文本,然后发送到MVC项目中的WCF服务。 but it gives "Error: 413 “Request Entity Too Large”. I tried a small file & its works. but more than 200kb is not working well. i tried to convert stream, but I had no luck. so I decided to convert it into string & pass it.但它给出“错误:413“请求实体太大”。我尝试了一个小文件及其工作。但超过 200kb 无法正常工作。我尝试转换 stream,但我没有运气。所以我决定转换它进入字符串并传递它。

My HTML Page -我的 HTML 页面 -

在此处输入图像描述

My WCF code -我的 WCF 代码 -

在此处输入图像描述

also, i checked online solution for that but its already done.另外,我检查了在线解决方案,但它已经完成了。

在此处输入图像描述

ERROR -错误 -

在此处输入图像描述

If anyone knows, how to convert string to Stream in javascript, then tell me.如果有人知道,如何在 javascript 中将字符串转换为 Stream,然后告诉我。 I am able to accept stream value.我能够接受 stream 值。

You can set the Maximum limit for receiving files in WCF like this:您可以像这样在 WCF 中设置接收文件的最大限制:

        WebServiceHost webServiceHost = new WebServiceHost(typeof(UploadService), uri);
        WebHttpBinding binding = new WebHttpBinding();
        binding.MaxReceivedMessageSize = Int32.MaxValue;
        webServiceHost.AddServiceEndpoint(typeof(IUploadService), binding, "WebServiceHost");
        webServiceHost.Open();

And you can try setting the upload size limit in HTML web.config.您可以尝试在 HTML web.config 中设置上传大小限制。

I found the solution after spending 1-2 days.我花了1-2天后找到了解决方案。 look into this url看看这个 url

https://cmatskas.com/upload-files-in-asp-net-mvc-with-javascript-and-c/ https://cmatskas.com/upload-files-in-asp-net-mvc-with-javascript-and-c/

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

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