简体   繁体   中英

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. The default dev server is 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. I cannot, for the life of me, figure out why Forms Authentication just won't work on 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. 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)

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.

What gives?

Found it!

It turns out that I had FormsAuthentication.Encrypt() return null. All of this caused by me manually building the ticket and setting the UserData field to null. UserData cannot be null.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM