Use a different port with RequireHttps filter in M

2019-07-16 05:10发布

Is it possible to use [RequireHttps] filter with a different port other than 443? I can't find much documentation about it.

2条回答
做自己的国王
2楼-- · 2019-07-16 05:17

Subclass it and override HandleNonHttpsRequest(). From within that method, you can manipulate the URL as necessary. (For example, you can call base.HandleNonHttpsRequest(), then modify the filterContext.Result property to include a port number.) Then use [MyCustomRequireHttps] instead of [RequireHttps] on your actions.

查看更多
劫难
3楼-- · 2019-07-16 05:32

Steve Sanderson's approach finally worked fine for me. No need to use the MVC2 filters.

查看更多
登录 后发表回答