title: The remote server returned an error: (500) Internal Server Error in mvc
body: <p>I am getting an error <code>The remote server returned an error: (500) Internal Server Error</code> with the code below:</p>
  
  <pre><code>private object ViewProgramDetails(Func&lt;string, JsonResult&gt; GetPrograms,string epicid)
  {
      try
      {
          var path = WebConfigurationManager.AppSettings["ProgramDetailsUrl"] + "?epicid=" + epicid;
  
          XElement elem = XElement.Load(path);
  
          var inputheaderdictionary = new Dictionary&lt;string, string&gt;();
          Dictionary&lt;string, string&gt; xmlDatadictionary = elem.Attributes().ToDictionary(attribute =&gt; attribute.Name.ToString().ToUpper(), attribute =&gt; attribute.Value);
  
          List&lt;string&gt; elementList = (from InputHeaderElements val in Enum.GetValues(typeof(InputHeaderElements)) select val.ToString().ToUpper()).ToList();
  
          foreach (string ele in elementList)
          {
              if (xmlDatadictionary.ContainsKey(ele))
              {
                  try
                  {
                      if (!ele.ToUpper().Equals("EPIC") &amp;&amp; !ele.ToUpper().Equals("EEQU"))
                      {
                          inputheaderdictionary.Add(ele, xmlDatadictionary[ele]);
                      }
                  }
                  catch (Exception)
                  {
                      //do nothing
                  }
              }
          }
  
          var result = inputheaderdictionary.ToList();
  
          return Json(result, JsonRequestBehavior.AllowGet);
      }
      catch (Exception)
      {
          return Json(string.Empty);
      }
  }
  </code></pre>
  
  <p>The exception is thrown from the line below:</p>
  
  <pre><code>XElement elem = XElement.Load(path);
  </code></pre>
  
  <p>What can I do to fix this error? Or at least to have a better idea about the exact cause?</p>