Quickest way to require authentication in asp.net webform?

前端 未结 4 353
不知归路
不知归路 2021-01-21 17:37

As of right now, I have the user register/log in and then if successful, redirect them to the homepage. However, this is extremely artificial as the user can simply type the ur

4条回答
  •  隐瞒了意图╮
    2021-01-21 18:22

    You can use the builtin asp.net sql membershiprovider and login controls for register and login this is implemented in the default web application project. Then you can check the value of Request.IsAuthenticated in page load and redirect to login page with Response.Redirect(loginPageUrl)

    1) http://www.asp.net/web-forms/overview/security good place to start.

    2) If you are using the ASP.NET builtin authentication in most scenarios you dont have to worry about cookies. IMO nothing wrong with cookies :)

    3) Usually you have to set this up in both. Generally you configure the auth method and the providers in web.config and do the redirection to login page in the codebehind or globally in global.asax.cs

    Hope this helps.

提交回复
热议问题