0

I am in the process of converting a Web Site Project To Web Application Project. The website project works perfectly with session variables in the .master file or .aspx file. During the conversion of web application all the session values used in .aspx/.master file throws an error "session does not found at the current context" Is there any workaround for using session variables on the master page.

In this scenario, when the user logs in the session values are set and depending on the session values the pages are redirected. I am checking the session values in the HTML body using <% C#code %>. It gives error on all the session variables used.

I am trying to follow the link below in this process How to convert ASP.NET website to ASP.NET web application.

<ul class="SM">
 <% if ((Convert.ToString(Session["ACCESS_LEVEL"])) == "ADMIN"))
     { %>
  <br />
      <li><a href="/FacultyDevSystem/Personal/FDS_AdminPersonalProfile.aspx? 
             fromwhere=LogAsAdmin" >Details</a></li>

     <% }
else if ((Convert.ToString(Session["ACCESS_LEVEL"])) == "DDIR"))
   { %> <br />

    <li><a href="/FacultyDevSystem/Personal/FDS_DDirPersonalProfile.aspx? 
         fromwhere=LogAsDDir"> Details</a>   
    </li>

 <% }  %>
  • 1
    Try to fix your code, its pretty messy, and hard to read in here – Reznik Dec 21 '19 at 12:43
  • The compiler doesn't know that your `.aspx` file's class derives from `System.Web.UI.Page`. Check your `<%@ Page Inherits="" %>` directive attribute. Also you will get compilation errors in `.aspx` files when the rest of the project doesn't build (because VS or the compiler won't have your final output assembly which contains the `Page` subclass that the `.aspx` file actually inherits from - in which case it's a benign error that you can ignore. Just make sure there are no other compiler errors besides those in `.aspx/ascx/ashx/asmx/asax/master` files. – Dai Dec 22 '19 at 16:52

0 Answers0