Visual Studio 2012 Express Forms 应用程序 httpRuntime targetFramework="4.5"
我刚刚通过 NuGet 添加了 SecurePages 模块。一切似乎都很好。除了提供的 SecurePagesConfig.cs 无法引用该模块外,我什么都没改变:
secureUrls.IgnoreUrl(@"(.*).css");
错误 1 当前上下文中不存在名称“secureUrls” MyAppPath\App_Start\SecurePagesConfig.cs 20 13 MyApp
.dll 在我的 bin 文件夹中,对 .dll 的引用在那里,我看到安装在 NuGet 中的包,引用添加到 web.config
有任何想法吗?谢谢
SecurePagesConfig.cs:
using System.Web;
using System.Web.Mvc;
using SecurePages;
using SecurePages.Infrastructure;
using SecurePages.Entities;
using SecurePages.Services;
using System.Text.RegularExpressions;
using System;
[assembly: WebActivator.PostApplicationStartMethod(typeof(MyWebApp.App_Start.SecurePagesConfig), "Start")]
namespace MyWebApp.App_Start {
public static class SecurePagesConfig {
public static void Start() {
RegisterSecurePagesConfigurations();
}
public static void RegisterSecurePagesConfigurations() {
//Ignore defaults
secureUrls.IgnoreUrl(@"(.*)\.css");
secureUrls.IgnoreUrl(@"(.*)\.js");
secureUrls.IgnoreUrl(@"(.*)\.png");
secureUrls.IgnoreUrl(@"(.*)\.jpg");
secureUrls.IgnoreUrl(@"(.*)\.gif");
// Securing a collection of pages with Regex
//SecurePagesConfiguration.Urls.AddRegex(@"(.*)account", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline);
//Securing a page by specifying its url
//SecurePagesConfiguration.Urls.Add("/cart");
//Registering a custom rule (Example for AppHarbor)
//SecurePagesConfiguration.RegisterCustomMatchRule(c => string.Equals(c.Request.Headers["X-Forwarded-Proto"], "https", StringComparison.InvariantCultureIgnoreCase));
//For testing only. By default, secure pages will ignore all request from localhost
#if DEBUG
SecurePagesConfiguration.IgnoreLocalRequests = false;
//Optional
//SecurePagesConfiguration.HttpRootUrl = "http://localhost:50535/";
//SecurePagesConfiguration.HttpsRootUrl = "https://localhost:44300/";
#endif
}
}
}