且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Response.Write和Response.Redirect

更新时间:2023-12-05 22:49:28

我不知道你为什么使用response.redirect()?



尝试使用,



I don''t know why are you using response.redirect()?

Try to use,

Page.ClientScript.RegisterStartupScript(Page.GetType(), "my", "alert("Error message");", true)
Response.Redirect("Configuration.aspx",false);





如果您还有其他问题,请告诉我。



If you have any further problem, So please let me know.


您好,



在将任何标头/数据发送到客户端之前,应使用Response.Redirect。将忽略任何响应正文内容,例如原始URL指示的页面中显示的HTML文本或Response.Write文本。此外,当处理Redirect方法时,终止当前页面中的代码执行,因此页面中的后续代码也将被忽略。如果你真的想显示错误信息,那么你可以这样做

Hello,

Response.Redirect should be used before sending any headers/data to the client. Any response body content such as displayed HTML text or Response.Write text in the page indicated by the original URL is ignored. In addition, code execution in the current page is terminated when the Redirect method is processed, so subsequent code in the page will also be ignored. If you really really want to display the error message then you can do it


  1. 将错误信息存储在会话中,并将密钥作为页面名称( Configuration.aspx)以及Configuration.aspx运行时显示它并将其从会话中删除
  2. 发送包含javascript的响应,该响应将显示错误并使用

  1. Store the error message in session with key as the page name (Configuration.aspx) and when the Configuration.aspx runs display it and remove it from session as well
  2. Send a response containing javascript which will show the error and use
location.replace(newURL)

将用户发送到Configuration.aspx。

to send user to Configuration.aspx.





问候,



Regards,