Monday, 16 May 2011

,

Explain cookies

  1. Cookies is a small text file sent by web server and saved by web browser on client machine.
  2. Common use of cookies is to remember last logged in time of a visitor.
  3. Usually cookies are not used to store sensitive information's like passwords without prior encryption as they are just a plain text.
  4. Cookie size is limited to 4096 bytes. So cookies are used to store small amounts of data, often just user id.
  5. Also, number of cookies is limited to 20 per website. If you make new cookie when you already have 20 cookies, browser will delete oldest one.

To check if a browser accepts cookies, use below code in C# :

if (Request.Browser.Cookies)
{
     // Cookies supported
}
else
{
     // Web browser not supports cookies
}



Ref : here

Sunday, 15 May 2011

,

Avoid viewstate tampering

Viewstate store's value in a hidden field, Developer are keen to know on how to avoid someone from tampering viewstate data.
One should encrypt the view-state data to avoid someone from tampering it.
To encrypt use the below code in webconfig.  
<system.web>
      <pages ViewStateEncryptionMode="Always" />
</system.web>

Ref : here, here