ASP.NET forms authentication - auto login with a test account while debugging?

后端 未结 7 1854
囚心锁ツ
囚心锁ツ 2020-12-31 18:21

I have a web application that uses the asp.net membership and role providers to allow logins that are members of certain roles to have access to various pages depending on

7条回答
  •  囚心锁ツ
    2020-12-31 19:09

    In the Application_AuthenticateRequest method (aka the Applications AuthenticateRequest event) in the global.asax file, add code that checks if you are running the site within the debugger (something like system.Diagnostics.Debugger.IsAttached) and, if you are, have it create the login ticket, create the cookie and attach it to the session. The FormsAuthentication library provides what you need if hte membership provder doesn't have it.

提交回复
热议问题