Showing posts with label Request Entity Too Large Web API issue. Show all posts
Showing posts with label Request Entity Too Large Web API issue. Show all posts

Monday 14 December 2015

Request Entity Too Large Web API issue

Please put the below code on OnStart Method.

config.MaxReceivedMessageSize = 2147483647; // use config for this value

  protected override void OnStart(string[] args)
        {
            //while (!Debugger.IsAttached) Thread.Sleep(1000);

            var config = new HttpSelfHostConfiguration("http://localhost");
            config.MaxReceivedMessageSize = 2147483647; // use config for this value
            config.Routes.MapHttpRoute(
               name: "",
               routeTemplate: "{controller}/{action}/{id}",
               defaults: new { id = RouteParameter.Optional }
           );
            HttpSelfHostServer server = new HttpSelfHostServer(config);
            server.OpenAsync().Wait();
        }