Asp.net markup exception tricks

How can I catch exceptions from using controls in markup?

For example, I have the following code

<asp:XmlDataSource ID="XmlDataSource1" 
                   runat="server" 
                   DataFile="http://feeds.feedburner.com/"
                   XPath="rss/channel/item [position()<=10]"></asp:XmlDataSource>

If feedburner is disabled for any reason, where is the exception thrown and how to do it?

+3
source share
2 answers

I would probably resort to setting the code properties and manually processing the data binding in the try / catch block. This will allow you to have an exception and throw some kind of error message.

+2
source

You can always let it go to Application_ErrorGlobal.asax.cs if you have any global error handling in place.

+1
source

Source: https://habr.com/ru/post/1717065/


All Articles