2011-02-28 4 views

答えて

0

あなたはRequireSsAttributeを意味しますか? http://aspnet.codeplex.com/SourceControl/changeset/view/63930#391756

+0

いいえ、私はRequireHttpsAttributeを意味します。 http://msdn.microsoft.com/en-us/library/system.web.mvc.requirehttpsattribute.aspx名前を変更していない限り。あなたは名前が変更されたことを意味していますか? –

8

私はちょうどASP.NET MVC 3 RTMのソースをダウンロードしてSystem.Web.Mvcプロジェクトでそれを見つけた:

namespace System.Web.Mvc { 
    using System; 
    using System.Diagnostics.CodeAnalysis; 
    using System.Web.Mvc.Resources; 

    [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "Unsealed because type contains virtual extensibility points.")] 
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)] 
    public class RequireHttpsAttribute : FilterAttribute, IAuthorizationFilter { 

     public virtual void OnAuthorization(AuthorizationContext filterContext) { 
      if (filterContext == null) { 
       throw new ArgumentNullException("filterContext"); 
      } 

      if (!filterContext.HttpContext.Request.IsSecureConnection) { 
       HandleNonHttpsRequest(filterContext); 
      } 
     } 

     protected virtual void HandleNonHttpsRequest(AuthorizationContext filterContext) { 
      // only redirect for GET requests, otherwise the browser might not propagate the verb and request 
      // body correctly. 

      if (!String.Equals(filterContext.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase)) { 
       throw new InvalidOperationException(MvcResources.RequireHttpsAttribute_MustUseSsl); 
      } 

      // redirect to HTTPS version of page 
      string url = "https://" + filterContext.HttpContext.Request.Url.Host + filterContext.HttpContext.Request.RawUrl; 
      filterContext.Result = new RedirectResult(url); 
     } 

    } 
} 
+0

あなたはcodeplexソースをブラウズして見ることができないのは面白いことです。 –

関連する問題