如何在基于ASP.NET MVC的站点中的一些页面上使用HTTPS?
Steve Sanderson在Preview 4上有一个很好的教程,关于如何以一种干燥的方式做到这一点,请访问:
http://blog.codeville.net/2008/08/05/adding-httpsssl-support-to-aspnet-mvc-routing/
Preview 5有没有更好的/更新的方式?
发布于 2010-03-02 05:03:31
如果您使用的是ASP.NET MVC 2 Preview 2 or higher,您现在可以简单地使用:
[RequireHttps]
public ActionResult Login()
{
return View();
}
不过,作为mentioned here,order参数值得注意。
发布于 2009-07-12 20:01:04
MVCFutures有一个'RequireSSL‘属性。
(在你更新的博客文章中感谢亚当的pointing that out )
只需将其应用于您的操作方法,如果您希望Redirect=true://请求自动变为https://:
[RequireSsl(Redirect = true)]
发布于 2009-08-25 20:20:33
以下是Dan Wahlin最近发布的一篇文章:
http://weblogs.asp.net/dwahlin/archive/2009/08/25/requiring-ssl-for-asp-net-mvc-controllers.aspx
他使用ActionFilter属性。
https://stackoverflow.com/questions/156748
复制相似问题