0

I have the following code that retrieves a link to the latest post from the blog subsite:

XDocument doc = XDocument.Load("http://www.mysite.com/blog/syndication.axd");
XElement node = doc.Descendants("item").FirstOrDefault();
string text = node.Element("title").Value;
string uri = node.Element("link").Value;

The code always worked fine. This week I added ELMAH.MVC via NuGet as a Package Reference. As soon as I deploy the web.config file with the added ELMAH sections, I get the following error:

System.Web.HttpException (0x80004005): Error executing child request for handler 
'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. 
---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
   at System.Net.HttpWebRequest.GetResponse()
   at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
   at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
   at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
   at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
   at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings, XmlParserContext inputContext)
   at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)

If I put the old web.config file back, the error goes away.

Any idea why adding ELMAH would cause XDocument.Load to fail?

Rich Bennema
  • 10,295
  • 4
  • 37
  • 58
  • 2
    What is the error on the server? – SLaks Nov 01 '12 at 17:11
  • 1
    And what happens if you just fetch the XML file with a browser? – Jon Skeet Nov 01 '12 at 17:14
  • @SLaks: if you move your comment to an answer, I'll mark it as accepted. I had been focusing on XDocument.Load, when I needed to be looking for the inner exception. Adding ELMAH to the main site was taking down the entire blog subsite. As soon as I added elmah.dll to the bin directory of the blog subsite, both the blog site and this code started working again. Thanks SLaks and Jon! – Rich Bennema Nov 01 '12 at 17:24

1 Answers1

2

You need to look at your ASP.Net site and find the server-side error.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964