您的位置:首页 > 其它

关于 context.Response.Redirect 跳转问题 .

2014-11-20 09:09 211 查看
查看这篇帖子Response.Redirect 发现的问题
1:采用ajax方式提交给IHttpHander

因为你是使用的异步请求的方式,页面自然不会跳转(帖子已经说明),这个时候context 对象应该被挂起了吧

要想跳转 可采用

a:IHttpHander 的返回值在跳转

b:

[csharp]
view plaincopyprint?

context.Response.Write(string.Format("window.location.href='{0}';", “你跳转的路径"));

context.Response.Write(string.Format("window.location.href='{0}';", “你跳转的路径"));


如果web.config 中添加

[html]
view plaincopyprint?

<add verb="*" path="*.ashx" type=" System.Web.IHttpHandler"/>
<add verb="*" path="*.ashx" type=" System.Web.IHttpHandler"/>


b方式也无法跳转(已经测试过,不知道原因,可能更IHttpHander 请求关联...)

2:当然就是非ajax方式请求 IHttpHander 中的

[csharp]
view plaincopyprint?

context.Response.Redirect

context.Response.Redirect


是ok的 千万不要采用上面的b方式 因为那是直接输出 到当前页面

[javascript]
view plaincopyprint?

window.location.href=‘你跳转的路径’
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: