I have written below code in .aspx.cs file.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Convert.ToString(Session["IsRedirect"]).ToLower() != CMS.CMSHelper.CMSContext.CurrentAliasPath.ToLower())
{
SetLocationWisePage();
}
}
}
it is throwing below exceptions
Session state can only be used when enableSessionState
is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule
or a custom session state module is included in the <configuration><system.web><httpModules>
section in the application configuration.
But every time it does not throws error. sometimes it works and sometimes throw above error.
Can any one tell me what will be the cause for that.