The remote server returned an error: (500) Interna

2019-04-15 23:04发布

问题:

I get this error :

(The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.GetResponse())

suddenly in one of my windows applications made using c#. I have been using this application for years and have not got any issues till yesterday..It suddenly started throwing this error.

Below is my method and Url i am calling :

   public string CallOnlineUrl() {    
        try {
          Uri onlineupdateUrl = new Uri("https://billett.tusenfryd.no/admin/update.aspx");
          HttpWebRequest req = (HttpWebRequest)WebRequest.Create(onlineupdateUrl);
               System.Net.WebResponse resp = req.GetResponse();
               System.IO.Stream stream = resp.GetResponseStream();
          //****some code
          //-------
         } catch(Exception ex) {
            ERPLog.AddLogEntry(ex.Message + ex.StackTrace);       
        }
      return cont;
    }

any help or suggestions to solve this are appreciated :)

回答1:

i figured out the issue here.Fiddler was of great help in detecting the issue... Actually on the server they made some changes for running the application on smartphones(Iphone/Andriod)...for this made some changes to global.asax application begin event...here they were checking for some Request.UserAgent..which was causing a runtime error and thus response returned was internal server. Anyways all is well once got the issue.