Error while setting UserAcces permission for WebForms?
        Posted  
        
            by 
                ksg
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by ksg
        
        
        
        Published on 2012-11-03T04:44:05Z
        Indexed on 
            2012/11/03
            5:00 UTC
        
        
        Read the original article
        Hit count: 195
        
I've created a class named BaseClass.cs and I've written a function in its constructor. 
Here's how it looks
public class BasePage:Page
{
    public BasePage()
    {
        setUserPermission();
    }
    private void setUserPermission()
    {
        String strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
        string strulr = strPathAndQuery.Replace("/SGERP/", "../");
        Session["Url"] = strulr;
        GEN_FORMS clsForm = new GEN_FORMS();
        clsForm.Form_Logical_Name = Session["Url"].ToString();
        clsForm.User_ID = Convert.ToInt32(Session["User_ID"]);
        DataSet dsPermission = clsForm.RETREIVE_BUTTON_PERMISSIONS();
        if (dsPermission.Tables.Count > 0)
        {
            if (dsPermission.Tables[1].Rows.Count > 0)
            {
                Can_Add = Convert.ToBoolean(dsPermission.Tables[1].Rows[0]["Can_Add"].ToString());
                Can_Delete = Convert.ToBoolean(dsPermission.Tables[1].Rows[0]["Can_Delete"].ToString());
                Can_Edit = Convert.ToBoolean(dsPermission.Tables[1].Rows[0]["Can_Edit"].ToString());
                Can_Print = Convert.ToBoolean(dsPermission.Tables[1].Rows[0]["Can_Print"].ToString());
                Can_View = Convert.ToBoolean(dsPermission.Tables[1].Rows[0]["Can_Print"].ToString());
           }
        }       
    }
}
I've inherited this class on my webform so that when the page loads, the setUserPermission function is executed. My webpage looks like this
public partial class Setting_CompanyDetails : BasePage
My problem is that I cannot access Session["Url"] in my BasePage. I'm getting the following error
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.
How can I solve this issue? Is this the right way to set UserPermission access? 
© Stack Overflow or respective owner