c# - 在 C# 中重定向页面之前设置超时

标签 c# asp.net

如何在这段代码中实现超时:

Response.Write(@"<script language='javascript'>alert('some alert');</script>"); 
Response.Redirect(Request.ApplicationPath);

我想在重定向后向用户显示消息。但是在我的解决方案中,操作发生得非常快,并且没有显示警报。

谢谢

最佳答案

删除 Response.Redirect 就可以了

Response.Write(@"
<script language='javascript'>
 alert('some alert');
  self.location = "/mypage.aspx";
</script>");

代码中的任何response.redirect都会忽略任何已经发送到浏览器的内容

关于c# - 在 C# 中重定向页面之前设置超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2984857/

相关文章:

c# - 为什么 MyService 中的 DbContext (ASP.NET) 为空?

c# - ASP.Net Listview 空 ItemTemplate 不显示

asp.net - 为什么用户将 ASP.NET 4.6 应用程序本地部署到 IIS 10 服务器后无法进行身份验证?

c# - Rhino Mocks - 通过多次调用模拟其返回值发生变化(即使传递相同参数)的方法

c# - 使用 Xamarin.forms 使用 RESTful API

c# - Global.asax app_error中捕获异常

c# - 使用 C# 字典中的基线 Object GetHashCode : no-no?

.net - System.Threading.Tasks - 限制并发任务的数量

c# - asp.net 中的货币格式字符串

.net - 在哪里存储加密 key