Skip to main content

Posts

Showing posts with the label ASP.NET MVC Cookie Implementation

Convert varbinary to string C#

How to convert varbinary to string c#? // convert varbinary to string c# public byte[] binaryData { get ; set ; } // FOR ASCII Encoding string ascii = System.Text.Encoding.ASCII. GetString (binaryData); OR // FOR UTF8 Encoding string utf = System.Text.Encoding.UTF8. GetString (binaryData); OR // FOR Unicode Encoding string unicode = System.Text.Encoding.Unicode. GetString (binaryData); OR // CONVERT BYTE ARRAY TO HEXA string AsString = SecurityManager. ByteToHexBitFiddle (binaryData); // CONVERT BYTE ARRAY TO HEXA public static string ByteToHexString (byte[] bytes) { char[] c = new char[bytes.Length * 2 ]; int b; for ( int i = 0 ; i < bytes.Length; i ++ ) { b = bytes[i] > > 4 ; c[i * 2 ] = (char)( 55 + b + (((b -10 ) > > 31 ) & -7 )); b = bytes[i] & 0xF ; c[i * 2 + 1 ] = (char)( 55 + b + (((b -10 ) > > 31 ) & -7 )); } return new string (...

How to create cookies in MVC 5 with C# .net?

We are using Request.Cookies for get the values of cookies and the Respone.Cookies are use to add the cookies. In the below example, used to Respone.Cookies for create/ add new cookies. i.e. 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 //This method id used to Create the cookies and assign the values in cookies . private static void SetCookies(UserSession userSession) {      HttpCookie cookie = HttpContext.Current.Request.Cookies[ "GlobalCookieName" ] ??      new HttpCookie( "GlobalCookieName " );      cookie.Values[ "CompanyID" ] = Convert.ToString(userSession.CompanyID);      cookie.Values[ "TenantId" ] = userSession.CompanyName;      cookie.Values[ "EmailID" ] = userSession.EmailID;      cookie.Values[ "UserType" ] = Convert.ToString(userSession.UserType);      cookie.Exp...