Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

VS 2008 Login Control

  • 20-11-2007 9:07am
    #1
    Closed Accounts Posts: 345 ✭✭


    Hi All,

    I would like to setup a login in asp.net, but I would like it database driven, as in the username and passwd stored in the db.

    I have done this before in asp.net, just wondering if there is any extra functionality in 2008 to make it easier, I haven't found anything online.

    Thanks


Comments

  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    Haven't really looked at 2008 but in ASP.NET 2.0 (VS 2005) there is a login control which can be linked to a database using a custom membership provider. It's not that straightforward so I often just do it myself.


  • Closed Accounts Posts: 345 ✭✭FindingNemo


    musician wrote: »
    Haven't really looked at 2008 but in ASP.NET 2.0 (VS 2005) there is a login control which can be linked to a database using a custom membership provider. It's not that straightforward so I often just do it myself.

    Cheers, was looking at that alright.
    Will have a look at 2008 and try set it up.
    Will give an update tomorrow to let you know how it is.


  • Moderators, Science, Health & Environment Moderators Posts: 9,035 Mod ✭✭✭✭mewso


    I find alot of value in create my own user class, then a user DAL (data access layer) then I can drop my 2 textboxes and button on a page and when they submit it's a simple case of userDAL.Login(username.text, password.text). Once the code is written it's quick and painless.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    It can actually be very simple in 2005 (haven't tried 2008 yet either). First off make sure you have a connection string called "localsqlserver" in your web.config (I can't remember how to get it to use different conn string names) pointing to the DB you want to use.

    Run the aspnet_regsql.exe tool, this will create all the tables, stored procedures etc that it needs in your database.

    Then run the ASP.net site config tool, in 2005 it's under the website menu option. Go to the provider tab, select either single provider, or multiple as needed (single is obviously easier), and test. If working ok go to the security tab, this will let you select your authentication type (windows/internet, internet in your case as you want to login with a form), add/maintain users, and set up rules (such as deny access to anonymous users)

    Create a form with the login control on it.

    add something like the following in your web.config (in the <system.web> section)

    <authentication mode="Forms"/>
    <forms name="LoginForm" loginUrl="LoginForm.aspx" />
    <authorization>

    And then run :)

    Musician's solution is a lot more powerfull and flexible, but depending on your needs the inbuilt functionality can be quick and easy.


  • Closed Accounts Posts: 345 ✭✭FindingNemo


    stevenmu wrote: »
    It can actually be very simple in 2005 (haven't tried 2008 yet either). First off make sure you have a connection string called "localsqlserver" in your web.config (I can't remember how to get it to use different conn string names) pointing to the DB you want to use.

    Run the aspnet_regsql.exe tool, this will create all the tables, stored procedures etc that it needs in your database.

    Then run the ASP.net site config tool, in 2005 it's under the website menu option. Go to the provider tab, select either single provider, or multiple as needed (single is obviously easier), and test. If working ok go to the security tab, this will let you select your authentication type (windows/internet, internet in your case as you want to login with a form), add/maintain users, and set up rules (such as deny access to anonymous users)

    Create a form with the login control on it.

    add something like the following in your web.config (in the <system.web> section)

    <authentication mode="Forms"/>
    <forms name="LoginForm" loginUrl="LoginForm.aspx" />
    <authorization>

    And then run :)

    Musician's solution is a lot more powerfull and flexible, but depending on your needs the inbuilt functionality can be quick and easy.


    Hi Steven,

    Thanks a million for that, I read up some info on aspnet_regsql and looks like I'll be using that. Thanks again


  • Advertisement
Advertisement