944,162 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1698
  • C# RSS
Jul 25th, 2006
0

Re: Simple ASP.Net Login Page using C#

Expand Post »
Hi,

I need some help for my project. I had finished up my login page and I can be logined.

The problem is that I want to allow new users to register themsevles before they can login but I have used various way I can't be directed to the Register.aspx because web.config. Is there anyway to redirect?

I had attached the following codes:

Web.config:

C# Syntax (Toggle Plain Text)
  1.  
  2. <configuration>
  3. <appSettings>
  4. <add key="localhost.DisplayString" value="http://localhost:1032/Webservices1/Service.asmx"/>
  5. </appSettings>
  6. <system.web>
  7. <authentication mode="Forms">
  8. <forms name=".IT3732Login" loginUrl="Login.aspx" protection="All" timeout="60"/>
  9. </authentication>
  10. <machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate" validation="SHA1"/>
  11. <authorization>
  12. <deny users="?"/>
  13. </authorization>
  14. <compilation debug="true"/>
  15. </system.web>
  16. </configuration>

Login.aspx

C# Syntax (Toggle Plain Text)
  1.  
  2. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <script Language="c#" runat="server">
  5. private void CheckLogin(object sender, EventArgs e)
  6. {
  7.  
  8. localhost.Service ds = new localhost.Service();
  9. if (ds.Check(TextBox2.Text, txtPassword.Text) == "OK")
  10. {
  11. FormsAuthentication.RedirectFromLoginPage(TextBox2.Text, false);
  12. string Usname = (string)Session["Username"];
  13. Usname = TextBox2.Text;
  14. Session["Username"] = Usname;
  15. }
  16. else
  17. {
  18. lblMSG.Text = "Login Fail. Please try again.";
  19. TextBox2.Text = "";
  20. txtPassword.Text = "";
  21. TextBox2.Focus();
  22. }
  23. }
  24. </script>
  25. <html xmlns="http://www.w3.org/1999/xhtml" >
  26. <head runat="server">
  27. <title>Coca-Cola - Login</title>
  28. </head>
  29. <body bgcolor="#cc0000">
  30. <form id="form1" runat="server">
  31. <div style="text-align: center">
  32. <span style="font-size: 16pt; color: white">= = = = = = = = = = = = = = = = = =<br />
  33. = = =The Coca-Cola Company = = =<br />
  34. = = = = = = = = = = = = = = = = = =</span><br />
  35. <br />
  36. <span style="color: white; font-size: 14pt;">= = = = = = =<br />
  37. --
  38. LOGIN --<br />
  39. = = = = = = =</span><br />
  40. </div>
  41. User ID:
  42. <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
  43. <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox2"
  44. ErrorMessage="User ID is required" ForeColor="White"></asp:RequiredFieldValidator><br />
  45. <br />
  46. Password:
  47. <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
  48. <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtPassword"
  49. ErrorMessage="Password is required" ForeColor="White"></asp:RequiredFieldValidator><br />
  50. <br />
  51. <asp:Button ID="btnLogin" runat="server" BackColor="White" Text="Login" Width="104px" OnClick="CheckLogin" />
  52. <asp:Button ID="btnBack" runat="server" BackColor="White" OnClick="btnBack_Click"
  53. Text="Back" Width="104px" />
  54. <br />
  55. <br />
  56. <a href="Register.aspx" target="_blank"><span style="font-size: 14pt; color: #ffffff">
  57. Register!</span></a><span style="font-size: 14pt; color: #ffffff"> </span>
  58. <br />
  59. <br />
  60. <asp:Label ID="lblMSG" runat="server" Height="30px" Width="212px"></asp:Label>
  61. </form>
  62. </body>
  63. </html>

http://img.photobucket.com/albums/v7...rush/Login.jpg --print sceen of my login.aspx
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
karkar_87 is offline Offline
6 posts
since May 2006
Aug 2nd, 2006
0

Re: Login page help

How to implement multitheading in 'C'
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gurudatta.verma is offline Offline
2 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: read text file
Next Thread in C# Forum Timeline: how to set default focus on button in winform





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC