codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  login system with asp.net  Stryker at 21:15 on Monday, October 25, 2004
 

Hi there, I'm really new to this stuff, I'm working on building something where a user thats already been created in a database (done that part) can log in and out of a system with a username and password and was just wondering if someone could provide me with a link or some sample code that i can use as a reference or starting point, cause I really have no idea where to start.. thanks

  Re: login system with asp.net  tgreer at 04:20 on Saturday, October 30, 2004
 

How much help do you need/want? Here's a headstart, let me know if you need more details. You can accomplish this with "Forms Authentication".

The most basic form of Forms Authentication is to create an "Authentication" tag in the web.config file, with user credentials (username and password) stored inside.

<authentication mode="Forms">
<forms loginUrl="/forum/login.html">
<credentials>
<user name="tgreer" password="password"/> </credentials>
</forms>
</authentication>

This is secure in that web.config cannot be browsed via a browser, so the credentials are (presumably) safe.

Of course you have to write the login.aspx page. It should have textboxes for a username and password, a button, and you would handle the button's click event like so:

private void btnLogin_Click(object sender, System.EventArgs e)
{
string username;
string password;

username = txtUsername.Text.Trim();
password = txtPassword.Text.Trim();

if (FormsAuthentication.Authenticate(username,password))
{
FormsAuthentication.RedirectFromLoginPage(username,false);
}
else
{
// redirect to a "failed login page"
}
}

ASP.NET checks to see if a user is authenticated when they browse to anything (well, according to the inheritance scheme of the web.config / app hierarchy). If not, they get redirected to login.aspx... the click event handles the authentication against web.config, and then takes them back to wherever they meant to go.

Of course this has shortcomings. You can't add or update user account info from within your app (no access to web.config), and, as you've stated, you want to keep your credentials in a database, not web.config.

Let me know that you understood what we've discussed so far, though, and then well take the next step.

Thomas D. Greer
www.tgreer.com


  Re: login system with asp.net  shurendy at 15:07 on Wednesday, December 01, 2004
 

Of course this has shortcomings. You can't add or update user account info from within your app (no access to web.config), and, as you've stated, you want to keep your credentials in a database, not web.config.

Hi Thomas,

I want to keep my credentials in the database, so i don't want to code them in the web.config.
But how can i program it in the web.config instead to set the persoon name and password.

  Re: login system with asp.net  tgreer at 16:10 on Wednesday, December 01, 2004
 

shurendy,

So, do you want the credentials in web.config, or not? If you DO want them in the web.config, use the example already posted in this thread.

If not, let me know what specific question you have, and I'll try to answer it.

Thomas D. Greer

<Added>

For an example using a database, see this thread:

http://www.codetoad.com/forum/23_23624.asp



  Re: login system with asp.net  Stryker at 23:13 on Thursday, December 02, 2004
 

Thomas, I was wondering if you can help me out with something.. I've completed the last part of my application that I was asking you about, I'm just having trouble with one minor thing. I have a datagrid displaying a shopping cart summary after a user 'checks out'. I want to be able to display the total cost of the shopping cart displayed. I've searched and read a lot of examples for adding totals to datagrids, but I'm finding it difficult to apply my code to that of the examples. the only two variables I really have to deal with are part_price (which is in my PART sql table) and item_qty (which is in the ORDERITEM table). I tried calculating the totals (part_price * item_qty) as the customer adds to the cart, but things like deleting from the cart and changing quantities complicates this too much. This is why I want to try and do it this way.

Peter.

  Re: login system with asp.net  tgreer at 23:28 on Thursday, December 02, 2004
 

Peter,

In this case, I would build the total as part of the stored procedure. This way it is returned to you already calculated as part of your recordset. Then you can just bind it to the datagrid, as you're doing with the rest of the data.

Alternatively, you perhaps not add the total to the datagrid at all. You could calcuate the total and put it into a completely separate control.

If you need more help, would you please start a separate thread, and show me some of your datagrid code?

T.









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..
•  Re: Security - Code verify
•  Job @ EarlySail
•  Job @ EarlySail (perl)
•  IPC problem


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007