Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

ASP Login and Logout Help for Ultra-Beginner (C#)

$
0
0
Hello everyone!

Okay, I have no idea how to do this :)

**Question 1:** Login page - I want a popup to occur that says to re-enter credentials if the user puts in the wrong info.

**Question 2:** Logout Function - I need to end the users session when they click the logout button. Can someone please tell me **exactly** what to put in the Logout.aspx.cs and the Logout.aspx pages? 

Code behind for Login page:

       
protected void btnLogin_Click1(object sender, EventArgs e)
        {
            ThisWS.Client client = new ThisWS.Client();
            //client.Endpoint.Address = new System.ServiceModel.EndpointAddress("https://svcThisService.svc/soap");
            WSAccess.ThisWS.clsTypesAuthResult response = client.Auth(this.txtUsername.Text, this.txtPassword.Text, txtAuthCode.Text);
            client.Close();
            this.lblErrorMessage.Text = response.Error;
            this.lblToken.Text = response.Token.ToString();
            int?[] cases = response.CaseNum;

            //Session.Add("Username", this.txtUsername.Text);   //User must re-login after an hour, since the token expires.
            //Session.Add("Password", this.txtPassword.Text);
            //Session.Add("AuthCode", this.txtAuthCode.Text);

            Session.Add("Token", response.Token);
            Session.Add("TokenExpires", DateTime.Now.AddHours(1));
            Session.Add("Cases", cases);
            Session.Add("PartyNameId", response.PartyNameID);
            Response.Redirect("ListCases.aspx");



.ASPX code I have for the login form:

    
<p class="redtext">Please use the form below to login.</p><div class=""><form id="form1" runat="server"><div><table class="auto-style1"><tr><td class="auto-style2">Your Username:</td></tr><tr><td><asp:TextBox ID="txtUsername" runat="server" Width="241px" MaxLength="255"></asp:TextBox></td><td>&nbsp;</td></tr><td>&nbsp;</td><tr><td class="auto-style2">Your Password:</td></tr><tr><td><asp:TextBox ID="txtPassword" runat="server" Width="239px"></asp:TextBox></td><td>&nbsp;</td></tr><tr><td class="auto-style2" hidden="hidden">Authentication code: </td><td><asp:Label ID="txtAuthCode" runat="server" Width="244px" Visible="False">000</asp:Label></td><td>&nbsp;</td></tr><tr><td><asp:Button ID="btnLogin" runat="server" Text="Click Here to Login" class="btn btn-primary btn-block" Width="175px" OnClick="btnLogin_Click1" /></td><td>&nbsp;</td></tr></table></div></form> </div>



Bridgette Bryant Designer, Writer, Human, Be-ing



Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>