Thursday, December 1, 2022

Error Page ASP.NET C# with query string

Errorpage.aspx page

 aspx page


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div><asp:Literal runat="server" ID="ltrError"></asp:Literal></div>

    <div class="h1 text-center text-danger">

        Oops

        <br />

        <h1 class="text-warning">something went wrong !!!</h1>

        <br />

        <div style="font-size:46px" class="text-success">Sorry for the Inconvenience</div>

        <br />

        <br />

    </div>

</asp:Content>


aspx.cs


 public partial class WebForm19 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            try

            {

                string r = Request.QueryString["r"].ToString();

                ltrError.Text = r;

            }

            catch

            {

                ltrError.Text = "";

            }

        }

    }



------------------------

catch()

{

Response.Redirect("ErrorPage.aspx?r=" + ex.Message);

}

No comments:

Post a Comment