简体   繁体   English

如何使IIS Express与表单身份验证一起使用

[英]How to get IIS Express to work with Forms Authentication

So I've just started working on a new ASP.NET project using VS 2012 and .NET 4.5. 因此,我刚刚开始使用VS 2012和.NET 4.5进行新的ASP.NET项目。 The default dev server is IIS Express. 默认的开发服务器是IIS Express。 I'm using Forms Authentication, which works on my previous project running on .NET 4.0, developed on VS 2010, and debugged on Cassini. 我使用的是Forms Authentication,它可用于我先前在.NET 4.0上运行,在VS 2010上开发并在Cassini上调试过的项目中。 I cannot, for the life of me, figure out why Forms Authentication just won't work on IIS Express. 我一辈子都无法弄清楚为什么表单身份验证在IIS Express上不起作用。

The conditions are: 条件是:

  • I use the default Authentication Ticket 我使用默认的身份验证票证
  • I checked in Chrome, the cookie's there when I log in and gone when I log out. 我签入了Chrome,当我登录时Cookie在那里,而当我退出时Cookie消失了。 Forgive me for I am a noob, but that's how it's supposed to work, right? 原谅我,因为我是菜鸟,但这就是它应该起作用的方式,对吗?
  • I've enabled both Anonymous Auth and Windows Auth on my IIS Express (I opened properties panel on my Project File and set it from there) 我已经在IIS Express上启用了匿名身份验证和Windows身份验证(我在“项目文件”中打开了属性面板,并从此处进行设置)

Every time I log in and try to access a protected page, I get bounced back to my login page. 每次登录并尝试访问受保护的页面时,我都会跳回到登录页面。 So I set a breakpoint at Page_Load in my login page and see that after every login, Request.IsAuthenticated still evaluates to FALSE. 因此,我在登录页面的Page_Load处设置了一个断点,并看到每次登录后, Request.IsAuthenticated仍然评估为FALSE。

What gives? 是什么赋予了?

Found it! 找到了!

It turns out that I had FormsAuthentication.Encrypt() return null. 原来我有FormsAuthentication.Encrypt()返回null。 All of this caused by me manually building the ticket and setting the UserData field to null. 所有这些都是由我手动生成票证并将UserData字段设置为null引起的。 UserData cannot be null. UserData不能为null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 身份验证在Kestrel上失败但在IIS Express上失败 - Authentication failing on Kestrel but not on IIS Express 调试 IIS Express 认证问题 - Debugging IIS Express authentication issue MVC 5 身份验证在 IIS Express 中工作但不在 IIS 中 - MVC 5 Authentication working in IIS Express but not in IIS MVC 身份验证在 IIS 中不起作用(在 IIS Express 中起作用) - MVC Authentication not working in IIS (works in IIS Express) 无法使MSMQ具有MassTransit在IIS Express上工作 - Can't get MassTransit with MSMQ to work on IIS Express 窗体身份验证与IIS中禁用的窗体身份验证一起使用 - Forms Authetnication works with Forms Authentication disabled in IIS 我无法在IIS网站上使用Windows身份验证 - I can't get windows authentication to work on IIS website 通过带有 Windows 身份验证的 IIS 托管 mvc 应用程序,但我得到 IIS APPPOOL\\ APP 我需要连接的 Windows 用户(与 IIS express 一起使用) - Hosting a mvc app via IIS with windows authentication, but I get IIS APPPOOL\ APP I need the windows user that connects (works with IIS express) IIS Express中使用Active Directory进行MVC身份验证/授权 - MVC Authentication/Authorization with Active Directory in IIS Express MVC4 / IIS / Forms身份验证SSO问题 - MVC4 / IIS / Forms Authentication SSO issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM