Asp.net mvc RequireAttribute的源在哪里?
ASP.NET MVC包含强制SSL连接的属性RequireHttpAttribute,但是在查看codeplex时,找不到它的源文件。我找的地方不对吗?你的意思是要求表扬吗?Asp.net mvc RequireAttribute的源在哪里?,asp.net-mvc,codeplex,Asp.net Mvc,Codeplex,ASP.NET MVC包含强制SSL连接的属性RequireHttpAttribute,但是在查看codeplex时,找不到它的源文件。我找的地方不对吗?你的意思是要求表扬吗? 你的意思是要求礼物吗? 我刚刚下载了的源代码,并在System.Web.Mvc项目中找到了它: namespace System.Web.Mvc { using System; using System.Diagnostics.CodeAnalysis; using System.Web.Mvc.
你的意思是要求礼物吗?
我刚刚下载了的源代码,并在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);
}
}
}
我刚刚下载了的源代码,并在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);
}
}
}
不,我是说RequireAttribute。除非他们重新命名它。你是说它被重命名了吗?不,我是说RequireAttribute。除非他们重新命名它。您是否暗示它已被重命名?有趣的是,您无法通过浏览codeplex源来查看它。有趣的是,您无法通过浏览codeplex源来查看它。