简体   繁体   中英

Error Message in ASP.NET Web Forms

I have this code in my page:

 protected void btn_add_Click(object sender, EventArgs e)
 {
      Session["truck_id"] = truck_id;
      Session["user_id"] = user_id;
      Session["usertype"] = usertype;
      if (usertype == "viewer")
      {
          Response.Write("Sorry, you do not have access to this page.");
          Response.StatusCode = 401;
          Response.End();
      }
      Response.Redirect("JobOrderForm.aspx");
}

I have logged in as viewer and the error message is this

在此处输入图片说明

How can I change it to Unauthorized Access ?

Change this:

Response.Redirect("JobOrderForm.aspx");

To this:

Response.Redirect("/JobOrderForm.aspx");

/ refers to the root directory. This may help because probably this page and redirected page is not in the same folder.

You have an error on your page. Have you tried debugging it? Set a breakpoint on the first line in the btn_add_Click method and step through to see which line is causing the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM