2009-04-29 85 views
2

我的Web服务支持flex/flash客户端,并且在unhandeld异常时抛出自定义错误,以扩展System.ServiceModel.FaultException。需要覆盖来自asmx web服务的Http响应代码

我已被告知,如果HTTP响应代码为200不同,这是记录为柔性/闪存错误的Flex /闪光无法读取这些自定义的故障: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

你可能需要改变响应状态代码之前添加以下代码:

HttpContext.Current.ClearError() 

这应该保持您的状态代码更改从得到覆盖。

+0

我将此行添加到Application_PreSendRequestHeaders()和Application_EndRequest()。 故障返回码仍为500。 此代码(ServiceLayer项目的global.asax)是否可能未执行? – 2009-04-30 22:34:03

相关问题