Tuesday, October 22, 2013

Unhandle Exception with error Error.aspx and Application_Error

Error.aspx
    <form id="form1" runat="server">
    <div>
    <center>
  <div class="ContentHead">ERROR</div><br /><br />
  <asp:Label ID="Label_ErrorFrom" runat="server" Text="Label"></asp:Label><br /><br />
  <asp:Label ID="Label_ErrorMessage" runat="server" Text="Label"></asp:Label><br /><br />
</center>
    </div>
    </form>
..........
protected void Page_Load(object sender, EventArgs e)
        {
            Label_ErrorFrom.Text = Request["Err"].ToString();
            Label_ErrorMessage.Text = Request["InnerErr"].ToString();

        }

Global.asax
       void Application_Error(object sender, EventArgs e)
        {
            Exception myEx = Server.GetLastError();
            String RedirectUrlString = "~/Error.aspx?InnerErr=" +
                myEx.InnerException.Message.ToString() + "&Err=" + myEx.Message.ToString();
            Response.Redirect(RedirectUrlString);
            // Code that runs when an unhandled error occurs

        }

0 comments:

Post a Comment

Popular Posts

Recent Posts

Text Widget

Powered by Blogger.

Find Us On Facebook

Flickr Images

Recent Posts

Video Of Day

Random Posts

Facebook

Random Posts

Advertising

Popular Posts