c# - Accessing Form Authentication Ticket -


I am collecting user details with the form authentication cookie.

  FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket (1, username, Dettaimkab, Dettaimkab. Adminets (timeout) false}; string Ankriptedtetik = Forms Attifikeshn. Encrypt (Othtiket); Actiteepikiki Athkuki = new hTTP cookie (form Attifikeshnkformskukinam, Ankriptedtet); Acteepeepitiakstikkantent. response. how to Add cookies (authCookie);  

I found cookies and user details (AuthTicket) You can get code that you can use as the following:

p>

  // the delete retrieves the cookie with your custom forms by Attifikeshntiket. HttpCookie authCookie = HttpContext.Current.Request Kkukij [Formattaaktifikeshnkformkukinam]; // Formetattifikeshntiket cookies. value property FormAssistationTicket A UthTicket = Formatting. Decrypt (authCookie.Val Ue); // "authTicket" variable now completes with your original, Custom FormsAuthenticationTicket, // user-specific custom data. You can then check that the FormsAuthenticationTicket's // .name property is for the correct user, and the ticket To do the relevant work together. // Here, we only write user-specific data on the HTPP response stream. If (authTicket.Name == txtUserName.Text) {Response.Write (authTicket.UserData); } Can  

What makes the above code txtUserName.Text as the context of things, so it is a full Apeepiaks page to paste into an empty Aspiknet webform Here's how it works:

  & lt;% @ page language = "c #"% & gt; & Lt;% @ import namespace = "System.Web.Security"%> & Lt ;; DOCTYPE HTML PUBLIC "- // W3C // DTT XHTML 1.0 Transcription // N" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> & Lt; Script runat = "server" & gt; Secure Zero Page_Old (Object Sender, EventAGRS E) {Double Timeout = 15.00; If (! IsPostBack) {FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket (1, txtUserName.Text, DateTime.Now, DateTime.Now.AddMinutes (timeout), incorrect, "This is my secret user-specific data"); String EncryptedTatic = Formatting Encrypt (authTicket); HttpCookie authCookie = New HttpCookie (Form Notification.FirmKookname, EncryptedTicket); HttpContext.Current.Response.Cookies.Add (authCookie); } Else {// retrieves the cookie contains your custom Formatifikeshntiket HttpCookie authCookie = HttpContext.Current.Request.Cookies [FormsAuthentication.FormsCookieName]; // Deletes the form attestationTalk for receiving cookies. Value Property Form Afrification Ticket Authoritcl = Form Unass. Duplicate (authCookie.Value); // The "authTicket" variable now completes with your original, custom FormsAuthenticationTicket, // user-specific custom data. You can then check that the FormsAuthenticationTicket's // property name is for the correct user, and the relevant work with the ticket to do. // Here, we only write user-specific data on the HTPP response stream. If (authTicket.Name == txtUserName.Text) {Response.Write (authTicket.UserData); }} & Lt; / Script & gt; & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Title & gt; Form authentication login & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form id = "form1" runat = "server" & gt; & Lt; Div & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; Username: & lt; / Td> & Lt; TD & gt; & Lt; ASP: text box id = "texturizer name" run = "server" & gt; & Lt; / Asp: text box & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; Password: & lt; / Td> & Lt; TD & gt; & Lt; ASP: Text Box ID = "TextType" Runat = "Server" & gt; & Lt; / Asp: text box & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; ASP: Button ID = "Button 1" Runat = "Server" Text = "Login" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -