【问题标题】:response redirect from .ashx file来自 .ashx 文件的响应重定向
【发布时间】:2011-01-04 04:09:35
【问题描述】:

我有 ashx 文件,我想从 ashx 重定向到 aspx 页面。有什么解决办法?

【问题讨论】:

    标签: .net ashx


    【解决方案1】:
    void ProcessRequest(HttpContext context)
    {
         context.Response.Redirect(newUrl);
    }
    

    【讨论】:

      【解决方案2】:

      使用 context.Response.Redirect(newUrl);结果页面显示:

      “对象已移至here。”

      更新: 发生这种情况是因为我退出了,在这种情况下,答案是使用 FormsAuthentication.RedirectToLoginPage();

      【讨论】:

        【解决方案3】:

        我找到了一个解决方案,它应该可以正常工作:

        context.Response.ContentType = "text/plain";
        
        if (controlcase)
        {
            //Write code, what you want...
        
            context.Response.Write("This is result");
        }
        else
        {
            context.Response.Write("<script>location.href='url you want to redirect'</script>");
        }
        

        【讨论】:

          猜你喜欢
          • 2016-03-22
          • 1970-01-01
          • 1970-01-01
          • 2012-05-24
          • 2023-01-26
          • 2018-03-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多