代码之家  ›  专栏  ›  技术社区  ›  sympatric greg

需要从asmx web服务重写Http响应代码

  •  2
  • sympatric greg  · 技术社区  · 17 年前

    我被告知,如果http响应代码与200不同,flex/flash无法读取这些自定义故障。这被记录为flex/flash错误: http://bugs.adobe.com/jira/browse/SDK-11841

    我需要在出现未处理的异常时重写http返回代码。我试图通过将此代码包含在global.asax中来实现这一点(此黑客行为已被记录为一种解决方法):

    protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
    {
        if (Response.StatusCode != 200)
        { // fix response code for flex
            Response.StatusCode = 200;
        }
    }
    
    protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
    {    
        if (Response.StatusCode != 200)    
        { // fix response code for flex        
             Response.StatusCode = 200;
         }
    }
    

    但遗憾的是,当遇到未处理的异常时,我的http返回代码返回为500

    1 回复  |  直到 17 年前
        1
  •  1
  •   jellomonkey    17 年前

    在更改响应状态代码之前,您可能需要添加以下代码:

    HttpContext.Current.ClearError()
    

    推荐文章