Status 500 Internal Server Error in IE-11 with Ang

2020-03-31 06:13发布

问题:

I am implementing single page application(SPA) using of Angular Js, MongoDb. And I am using rest call with promises. Rest call working fine in Chrome, Mozila browser which is using for development. But rest call is not working in IE-11. It is giving me 500 Internal Server Error.

I am not able to find out line of rest call. Because it is not showing line number. But I can share sample code of rest call.

  Rh.all('apicall').get('dbname/_aggrs/'+ ar_dep +'?avars=' + query).then(function (d) {

       console.log("response data");

      });

Above call is not printing console. Because It is breaking in IE-11, But these rest call working fine in other browser. If I putt direct path not with variable then it is working in IE-11.
Working Rest Call below

Rh.all('apicall').get('dbname').then(function (d) {

           console.log("response data");

          });

NETWORK in Console(IE-11)

IN CHROME

I am updating my question. Because I found some difference parsing url, Because of restheart.

IN CHROME:

Rh.all('apicall').get('dbname/_aggrs/'+ ar_dep +'?avars=' + query)

After parsing

localhost:8080/apicall/dbname/_aggrs/rout?avars={%22routes%22:%22US%22}

In query object I have routes:us. So in chrome it parsing %22--%22 place of " ".

IN IE-11

Rh.all('apicall').get('dbname/_aggrs/'+ ar_dep +'?avars=' + query)

After parsing

localhost:8080/apicall/dbname/_aggrs/rout?avars={"routes":"US"}

In IE-11, It is not parsing double qoutes to %22 %22. It is parsing same as string.

回答1:

A 500 error is always related to the server. The symptoms may only occur with a specific browser, but it is the server that is failing; the request that is being sent to the server is causing the server-side code to fail in some way.

Error 500 on its own is too generic; without knowing more details about the error, it is always very hard to diagnose, and frankly I won't be able to give you a definitive answer here.

At your end, you should rule out the obvious, and check your browser settings in IE. Specifically, any settings that might cause it to fail to communicate properly with the server. For example, make sure that cookies are enabled and are working properly.

But the first thing you should do is discuss with the vendor or developers of the API because they will have access to the server error logs, and they will want to know about it if their code is throwing a 500 error.

However, if you do want to investigate at your end, the fact that it is specific to one browser is a clue. If the other browsers are working, then what this tells us is that this one browser (IE11) is sending the request with something about it that is different to the other browsers, and it is that something that is triggering the server-side code to fail. This gives us something to work with in the investigation.

So the first thing to do is to examine the request in all browsers. Use the F12 dev tools in Chrome, Firefox and IE, and get to the point where you've made the same call in all three of them, and it works in FF and Chrome but not in IE11.

In the dev tools, you should now be able to examine the request details for all three. Compare them.

Start by looking at the request data -- ie the actual query string that was sent. If there are differences, consider whether any of these differences may be responsible for the error. Something may stand out obviously; eg if IE has truncated a variable or something like that. If this solves the problem, then great.

If it doesn't help, then you need to look in more detail. Maybe there are some differences but they don't look like they should break anything? Modern browser dev tools allow you to edit and re-send a request, so try editing the request in Chrome or Firefox's dev tools, and make the parameters the same as the ones from IE that failed. Now try re-sending that request. If you're lucky, this will cause the request to fail in the other browser, which will allow you to show that a specific set of data is the problem (rather than a specific browser). You mentioned that it's a third party API, so you'll then need to discuss with the API vendor to find out why that query breaks their API.

If you still haven't found the problem at this point, and you're sending identical queries in both browsers, and you're logged in as the same user, then the next step is to look at the request headers.

There is one request header that will definitely be different: the User Agent string. But there may be others too. Again, try re-sending request that works in Chrome, but with headers from the failing request in IE (including the UA string). Does the request now fail in Chrome? If so, narrow down which headers are different that make it fail.

Again, if this allows you to find a specific set of request data and headers that causes the problem, then you will need to discuss with the API vendor.

If all of this doesn't help, then try looking at the cookies. You already checked that cookies are working, so this seems like a long shot now, but again compare the cookies between browsers, and see if there's anything obviously different about them.

I hope the above is enough to help you diagnose the issue.