简体   繁体   中英

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. Both files are converted to text and then send to the WCF service in the MVC project. 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.

My HTML Page -

在此处输入图像描述

My WCF code -

在此处输入图像描述

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. I am able to accept stream value.

You can set the Maximum limit for receiving files in WCF like this:

        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.

I found the solution after spending 1-2 days. look into this url

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

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