为什么在我用 "location" 元素覆盖 SSL 设置后不再调用我的控制器操作过滤器?
Why is my controller action filter no longer invoked once I override SSL settings with a "location" element?
我有一个 ASP.NET MVC3 应用程序,其动作过滤器属性应用于控制器:
public class MyFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(
ActionExecutingContext filterContext)
{
filterContext.HttpContext.Response.Headers.Add(
"MyFilterAttribute", "entered" );
}
public override void OnResultExecuted(
ResultExecutedContext filterContext)
{
filterContext.HttpContext.Response.Headers.Add(
"MyFilterAttribute", "exited" );
}
}
[MyFilter]
public class MyController : Controller
{
public ActionResult MyAction()
{
return new EmptyResult();
}
}
MVC 路由映射 /MyPath/MyAction
到上面的 controller-action 对。
并且客户端代码调用 https://my.company.com/MyPath/MyAction
并转储响应 headers。
最初有效 - 我看到客户端收到的响应包含预期的两个 MyFilterAttribute
headers。
然后我添加一个location
元素到web.config:
<configuration>
// lots of stuff, then
<location path="MyPath">
<system.webServer>
<security>
<access sslFlags="SslNegotiateCert"/>
</security>
</system.webServer>
</location>
</configuration>
一旦我重新部署这些更改,响应 headers 不再包含两个 MyFilterAttribute
项。
将 location
添加到 web.config 是唯一的变化。删除它后,旧的预期行为又回来了。
添加 location
元素似乎以某种方式破坏了 MVC 属性。
可能是什么导致了这种行为?
sslFlags="SslNegotiateCert"
请求 IIS 打开相互验证的通道,这不是默认行为。我查看了 IIS 日志,它一直是 HTTP 403.16(客户端证书不受信任)。由于客户端证书是自签名的,IIS 不信任它,因此无法打开相互验证的通道。
要么我必须不使用 SslNegotiateCert
(这样客户端证书就不会传递给应用程序代码),要么我需要一个 IIS 信任的证书( 解释了如何实现) .
我有一个 ASP.NET MVC3 应用程序,其动作过滤器属性应用于控制器:
public class MyFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(
ActionExecutingContext filterContext)
{
filterContext.HttpContext.Response.Headers.Add(
"MyFilterAttribute", "entered" );
}
public override void OnResultExecuted(
ResultExecutedContext filterContext)
{
filterContext.HttpContext.Response.Headers.Add(
"MyFilterAttribute", "exited" );
}
}
[MyFilter]
public class MyController : Controller
{
public ActionResult MyAction()
{
return new EmptyResult();
}
}
MVC 路由映射 /MyPath/MyAction
到上面的 controller-action 对。
并且客户端代码调用 https://my.company.com/MyPath/MyAction
并转储响应 headers。
最初有效 - 我看到客户端收到的响应包含预期的两个 MyFilterAttribute
headers。
然后我添加一个location
元素到web.config:
<configuration>
// lots of stuff, then
<location path="MyPath">
<system.webServer>
<security>
<access sslFlags="SslNegotiateCert"/>
</security>
</system.webServer>
</location>
</configuration>
一旦我重新部署这些更改,响应 headers 不再包含两个 MyFilterAttribute
项。
将 location
添加到 web.config 是唯一的变化。删除它后,旧的预期行为又回来了。
添加 location
元素似乎以某种方式破坏了 MVC 属性。
可能是什么导致了这种行为?
sslFlags="SslNegotiateCert"
请求 IIS 打开相互验证的通道,这不是默认行为。我查看了 IIS 日志,它一直是 HTTP 403.16(客户端证书不受信任)。由于客户端证书是自签名的,IIS 不信任它,因此无法打开相互验证的通道。
要么我必须不使用 SslNegotiateCert
(这样客户端证书就不会传递给应用程序代码),要么我需要一个 IIS 信任的证书(