In certain applications, there might be a need to display the server exception, if any, raised during an AJAX call, for information/troubleshooting on the client. In this recipe, we will see how to retrieve the server exception and the XmlHTTPRequest statuses on the client.
We will go about by posting an AJAX request for a file retrieval from the server. We will intentionally throw an IO exception on the server and capture the same on the client.
Add a web form
Recipe3.aspx
to the current project.Add a DropDownList to the form. Set the value of each item of the DropDownList to a filename for retrieval from the server.
Thus, the complete ASPX markup of the form is as follows:
<form id="form1" runat="server"> <div align="center"> <fieldset style="width:350px;height:250px;"> <div id="contentArea"> Select the document to view:<br /><br /> <asp:DropDownList ID="ddDocumentList" runat...