问题描述
是否有可能由5秒延迟在一个asp.net页面的Response.Redirect?
Is it possible to delay the response.redirect in an asp.net page by 5 seconds?
像delay.response.redirect(myURL.aspx)
something like delay.response.redirect("myURL.aspx")
我需要的页面重定向之前运行jQuery的动画。
I need to run a jquery animation before the page redirects.
我不希望使用元刷新,如果我能帮助它,但如果这是唯一的办法还是最好的方法,那么请让我知道。
I don't want to use meta refresh if I can help it but if that's the only way or the best way then please let me know.
感谢
推荐答案
如果您发布到服务器,就没有办法影响到客户端了 - 所有的服务器所能做的就是等待。而在Web服务器睡眠很不好 - 耗尽线程池,坏的性能。
if you posted to the server, there's no way to affect client anymore - all server can do is wait. And sleeping in web server is very bad - exhausts thread pool, bad for performance.
你应该做的是在客户端上的延迟。另外,您也可以张贴到使用AJAX该网页 - 这是一个我会preFER。投递到服务器使用AJAX,然后更改location.href之前获得响应,并等待5秒钟(在JavaScript)
你甚至可以从服务器读取新位置(从AJAX调用返回的数据)
What you should do is delay on the client. Alternatively, you can post to that page using AJAX - that's the one I would prefer. Post to server using ajax, then get the response and wait 5 seconds (in javascript) before changing location.hrefYou can even read the new location from the server (from the data returned by ajax call)
这篇关于响应重定向之前asp.net延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!