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

来源:互联网 发布:aoi检测算法 编辑:程序博客网 时间:2024/05/17 08:22
查看这篇帖子Response.Redirect 发现的问题

1:采用ajax方式提交给IHttpHander

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

要想跳转 可采用

a:IHttpHander 的返回值在跳转

b:

[csharp] view plaincopyprint?
  1. context.Response.Write(string.Format("window.location.href='{0}';", “你跳转的路径"));  


如果web.config 中添加

[html] view plaincopyprint?
  1. <add verb="*" path="*.ashx" type=" System.Web.IHttpHandler"/>  


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

 

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

[csharp] view plaincopyprint?
  1. context.Response.Redirect  


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

[javascript] view plaincopyprint?
  1. window.location.href=‘你跳转的路径’  
0 0