如何在Firefox中实现ASP.NET 不弹出窗口的Windows Integrated Authentication

Follow these steps -
1. Open Firefox
2. Navigate to the url about:config
3. Locate the following preference names and put as the value the comma separated values of the address roots.
network.automatic-ntlm-auth.trusted-uris
network.negotiate-auth.delegation-uris
network.negotiate-auth.trusted-uris
assign values to all above preference names as your site - [url]http://yoursite[/url],http:yoursite:0000



本文转自 xhinkerx 51CTO博客,原文链接:http://blog.51cto.com/xhinker/128230,如需转载请自行联系原作者
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ASP.NET身份验证是一种用于验证用户身份的机制,它可以确保只有经过身份验证的用户才能访问应用程序的受保护部分。ASP.NET Core提供了多种身份验证方式,包括Cookie身份验证、JWT身份验证、OpenID Connect身份验证等。其,Cookie身份验证是最常用的一种方式。 以下是ASP.NET Core使用Cookie身份验证的示例代码: 1. 在Startup.cs文件的ConfigureServices方法添加身份验证服务: ```csharp services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = "/Account/Login"; options.LogoutPath = "/Account/Logout"; }); ``` 2. 在Startup.cs文件的Configure方法启用身份验证间件: ```csharp app.UseAuthentication(); ``` 3. 在需要进行身份验证的Controller或Action上添加[Authorize]特性: ```csharp [Authorize] public class HomeController : Controller { // ... } ``` 4. 在登录Controller使用SignInAsync方法进行登录: ```csharp public async Task<IActionResult> Login(LoginViewModel model) { // 验证用户名和密码 if (/* 验证通过 */) { // 创建用户标识 var claims = new List<Claim> { new Claim(ClaimTypes.Name, model.UserName) }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); // 登录 await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity)); // 跳转到首页 return RedirectToAction("Index", "Home"); } // 验证失败,返回登录页面 return View(model); } ``` 5. 在注销Controller使用SignOutAsync方法进行注销: ```csharp public async Task<IActionResult> Logout() { await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); return RedirectToAction("Index", "Home"); } ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值