Làm cách nào để thiết lập ứng dụng biểu mẫu web có nhận dạng và nợ để từ chối tất cả các trang ngoại trừ thông tin đăng nhập?Từ chối tất cả các trang mà không cần đăng nhập vào các Biểu mẫu Web Asp.net có Khung Nhận dạng và Owin
cấu hình trong web.config này không làm việc cho tôi:
<system.web>
<authorization>
<deny users="*"/>
</authorization>
<authentication mode="None"/>
Thông báo lỗi: Yêu cầu mô-đun lọc được cấu hình để từ chối yêu cầu nơi chuỗi truy vấn quá dài.
OWIN lớp khởi động:
public void ConfigureAuth(IAppBuilder app)
{
// Configure the db context, user manager and signin manager to use a single instance per request
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
// Configure the sign in cookie
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, Usuario>(
validateInterval: TimeSpan.FromMinutes(0),
regenerateIdentity: (manager, user) => manager.GenerateUserIdentityAsync(user))
}
});
cấu trúc dự án
Edit:
Mở web.config bên trong thư mục tài khoản có cấu hình này.
<configuration>
<location path="Manage.aspx">
<system.web>
<authorization>
<allow users="?"/>
</authorization>
</system.web>
</location>
</configuration>
Làm việc này cho trang Manage.aspx.
Tôi không muốn làm điều này cho mọi trang. Tôi muốn đưa vào web.config toàn cầu của trang web.
2016 ... Vẫn còn là lỗi ... liên kết của bạn có vẻ bị hỏng. – RokumDev