【发布时间】:2018-12-17 09:43:02
【问题描述】:
【问题讨论】:
【问题讨论】:
也许你可以使用 iis 的 Application_EndRequest 事件。
protected void Application_EndRequest(object sender, EventArgs e)
{
// you could decide whether to redirect according to the path and status code
string path = HttpContext.Current.Request.Path;
if (HttpContext.Current.Response.StatusCode == 400)
{
HttpContext.Current.Response.Redirect("/ErrorPage.aspx");
}
}
请不要忘记确保 wcf 在兼容模式下运行。
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"></serviceHostingEnvironment>
在您的服务之上
[AspNetCompatibilityRequirements(RequirementsMode =AspNetCompatibilityRequirementsMode.Allowed)]
public class CalculatorService : ICalculatorService
否则 Application_EndRequest 事件不会触发。
【讨论】: