1

I have to fill a partial view with a lot of data. I first do an ajax call on the server:

$.ajax({
    url: '/Monitoring/_Thresholds?workspaceID=' + workspaceID,
    type: "POST",
    data: new FormData(form),
    cache: false,
    contentType: false,
    processData: false,
}).success(function (result) {
    resultsDiv.innerHTML = result;
}).error(function (response) {
    resultsDiv.innerHTML = response.responseText;
});

However due to the large number of data it takes too long to do this and I get:

HTTP Error 502.3 - Bad Gateway

The specified CGI application encountered an error and the server terminated the process.

Most likely causes:

The CGI application did not return a valid set of HTTP errors. A server acting as a proxy or gateway was unable to process the request due to an error in a parent gateway.

Things you can try:

Use DebugDiag to troubleshoot the CGI application. Determine if a proxy or gateway is responsible for this error.

The BL stuff takes 2-3 seconds but rendering the view a lot more.

Is there any way to solve this?

Maxime Rouiller
  • 13,614
  • 9
  • 57
  • 107
Mihai Bratulescu
  • 1,915
  • 3
  • 27
  • 43
  • The error "502.3 - Bad Gateway" could means the error on the server side. I recommend you to use additionally [Fiddler](http://www.telerik.com/fiddler) or Developer Tools to make trace of HTTP traffic. You should debug the server code. Moreover the usage of `dataType: "html"` seems to me correctly. – Oleg Dec 15 '15 at 10:13
  • @Oleg There is no server error since on the server the view is rendered but never served – Mihai Bratulescu Dec 15 '15 at 10:15
  • Sorry, I don't understand what you mean ("never served"???, "The BL stuff"???). Can use set the breakpoint in your server code which process `/Monitoring/_Thresholds`? It will be called or not? What you see in HTTP trace? Do you send correct data to the server? Do you see some helpful information in the server response or only the same error message? – Oleg Dec 15 '15 at 10:20
  • @Oleg I added a breakpoint at the end of the view and it was hit. Therefore on the server everything ran well except that it took too long and the result was never served because an error message was served instead – Mihai Bratulescu Dec 15 '15 at 10:32
  • I think that you interpret the results which you see in the wrong way. It could be multiple reasons of the error. For example you can look at [the issue](https://github.com/aspnet/EntityFramework/issues/3818). It is not your case but the data returned from the controller action needed be processed and you can get the error "HTTP Error 502.3 - Bad Gateway" during the processing. I would recommend you to examine HTTP traffic first of all, then to make copy and pasted of returned HTML data, place the data on static HTML page and validate using https://validator.w3.org/. You can debug MVC code too – Oleg Dec 15 '15 at 11:00
  • One more reason of the error "HTTP Error 502.3 - Bad Gateway" is described [here](http://docs.asp.net/en/latest/publishing/iis.html). You should include more details about the problem in the text of your question. Do you have the problem on IIS? How looks the code of `_Thresholds` action? Is the same code work in case of returning small data? What is "too long" data in your case? How many MB/GB you try to return?... – Oleg Dec 15 '15 at 11:14
  • Is it a big view? https://github.com/aspnet/Razor/issues/635 – Stafford Williams Dec 15 '15 at 12:49
  • @StaffordWilliams yes, is memory the issue? – Mihai Bratulescu Dec 15 '15 at 12:59
  • Look at [the answer](http://stackoverflow.com/a/34292291/315935). Probably you have the same problem and use `async` in the method, but you skipped to include `await`? – Oleg Dec 15 '15 at 15:15
  • @Oleg no, it's not `async` – Mihai Bratulescu Dec 16 '15 at 03:07

1 Answers1

1

There's a known performance issue in rc1-final rendering large views.

Fix ready for rc2. Try to make the view smaller I guess.

Stafford Williams
  • 9,696
  • 8
  • 50
  • 101