Create App_Code/Utility/Browser.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
/// <summary>
/// Summary description for Browser
/// </summary>
public class Browser
{
public Browser()
{
//
// TODO: Add constructor logic here
//
}
public static void ClearBrowserData()
{
System.Web.HttpContext.Current.Response.Buffer = true;
System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
System.Web.HttpContext.Current.Response.Expires = -15000;
System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
System.Web.HttpContext.Current.Response.Cache.SetNoStore();
System.Web.HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.Web.HttpContext.Current.Response.AppendHeader("Cache-Control", "no-store");
System.Web.HttpContext.Current.Response.AppendHeader("Cache-Control", "Must-revalidate");
System.Web.HttpContext.Current.Response.AppendHeader("Cache-Control", "Proxy-revalidate");
}
public static void CrossSiteRequestForgery(HiddenField hfCSEF)
{
//Code start for Cross Site Request Forgery
Random randomobj = new Random();
HttpContext.Current.Session["randomno"] = randomobj.Next();
hfCSEF.Value = HttpContext.Current.Session["randomno"].ToString();
//End Code
}
}
No comments:
Post a Comment