-2

When I refresh or Ctrl+5 for few times continuously throws this error.Please help me...!

enter image description here

The actual Error is enter image description here

Actually Iam using a Url in my JS to get the Ip...When refreshing the page continuesly Its unable to get the Ip I think.So it shows the error.

here is the code How I get the IP

string url = string.Format("http://api.ipinfodb.com/v3/ip-city/?key={0}&ip={1}&format=json", APIKey, ipAddress);
using (WebClient client = new WebClient())
{
    string json = client.DownloadString(url);
    Location location = new JavaScriptSerializer().Deserialize<Location>(json);
jww
  • 97,681
  • 90
  • 411
  • 885
  • 1
    Have you read the error message? Because it is saying that it cannot display the _actual error_ that you're getting due to your configuration settings. Follow the instructions to change them so that you can see and show us the actual error. – Visual Vincent Nov 02 '18 at 09:52
  • The remote server returned an error: (503) Server Unavailable. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.WebException: The remote server returned an error: (503) Server Unavailable. – Praveen Kumar Rejeti Nov 02 '18 at 09:56
  • 2
    Please post the full error message (and Stack Trace) in your question. – Visual Vincent Nov 02 '18 at 09:58
  • 1
    For the record: [503 Service Unavailable](https://en.m.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_errors): _"The server is currently unavailable (because it is overloaded or down for maintenance)."_ – Visual Vincent Nov 02 '18 at 09:59
  • Actually I used a Url for getting the IP.... when getting the Url in method as follows ...Its working fine..But when I refreshes continuesly it gets error:...see the code follows... ` string url = string.Format("http://api.ipinfodb.com/v3/ip-city/?key={0}&ip={1}&format=json", APIKey, ipAddress); using (WebClient client = new WebClient()) { string json = client.DownloadString(url);` – Praveen Kumar Rejeti Nov 02 '18 at 09:59
  • 2
    Again, post the relevant information in your question, not the comments. To help you further identify the cause see: https://serverfault.com/a/401692 – Visual Vincent Nov 02 '18 at 10:02
  • I have added the actual issue in Question now, not in comments.Please have a look and help me out....for resolving this – Praveen Kumar Rejeti Nov 02 '18 at 10:09
  • 1
    OK so it's not your server throwing the error, but the one you're trying to get the IP information from. You need to provide error handling in your code. Wrap the web client code in a [`try/catch` statement](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/try-catch) and output your own error message (or whatever) to your site. You cannot fix the actual error as ipinfodb.com cannot manage/doesn't allow you to connect to it so many times. – Visual Vincent Nov 02 '18 at 10:15
  • 1
    Infact, [from their own documentation](https://ipinfodb.com/api): _"To remain the stabilities of free service, a rate limit of **2 queries per second** applied to our API servers. Any IP querying the API faster than this rate **will temporarily blocked by our firewall**. Your IP will permanently banned if your keep hitting the API server by ignoring this rate limit."_ – Visual Vincent Nov 02 '18 at 10:18
  • Hey Thanks. By keeping try catch. Im not getting the issue.Page is not getting crashed or throwing error page now. – Praveen Kumar Rejeti Nov 02 '18 at 10:22
  • 1
    No problem. `try/catch` allows you to catch errors and manage them yourself (see the Microsoft Docs that I linked earlier). You use the `catch` block to react to when one occurs. – Visual Vincent Nov 02 '18 at 10:24

2 Answers2

1

set web.config file this code.

Make sure you nest the customErrors tag somewhere inside your tag like this:

<system.web>
<customErrors mode="Off" />
</system.web>
ravi polara
  • 564
  • 3
  • 14
  • yeah given that ...but After that the eoor throws 503 – Praveen Kumar Rejeti Nov 02 '18 at 09:53
  • The remote server returned an error: (503) Server Unavailable. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.WebException: The remote server returned an error: (503) Server Unavailable. – Praveen Kumar Rejeti Nov 02 '18 at 09:55
  • This was the actual error thrown – Praveen Kumar Rejeti Nov 02 '18 at 09:55
1

As this yellow page stating there is a runtime error. Turn off the custom error mode in web config file <CustomErrors mode="Off"> and reproduce the same scenario. You will see the actual error on page. But don't do it on production.

  • The remote server returned an error: (503) Server Unavailable. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.WebException: The remote server returned an error: (503) Server Unavailable. – Praveen Kumar Rejeti Nov 02 '18 at 09:54
  • that was the actual error thrown – Praveen Kumar Rejeti Nov 02 '18 at 09:55
  • 1
    It sounds like your Security Token Service is not configured properly (or is having issues). MSDN has a good blog post about the various items you might check: http://blogs.technet.com/b/sykhad-msft/archive/2012/02/25/sharepoint-2010-nailing-the-error-quot-the-security-token-service-is-unavailable-quot.aspx – ravi polara Nov 02 '18 at 10:10
  • Hey, the actual error is mentioned in the Question again by Edit.Please have a look. Tq – Praveen Kumar Rejeti Nov 02 '18 at 10:11
  • From the stack trace it seems like the API which you are using to get the location from IP is returning "503 server not available error". If you see the stack trace, error is originating from DownDataInternal method which is responsible for ferching data from API endpoint. – Vibhu Mishra Nov 02 '18 at 10:25