Error with enablesessionstate attribute in Sharepoint

If you have a custom .aspx page that you have added through Sharepoint designer, you may get an error when you try to add attributes to the beginning of the file, like the EnableSessionState attribute. The error will appear similar to the one below:

Server Error in ‘/’ Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The enablesessionstate attribute on the page directive is not allowed in this page.
Source Error:

Line 1:  <%@ Page Language="vb"
MasterPageFile="~masterurl/default.master"
EnableSessionState="true"

 

 

The problem is that by default, Sharepoint does not allow server side code in .aspx pages by default. You need to enable this using PageParserPath. Add the PageParserPath inside of the PageParserPaths node of the web.config file, changing the virtual path to the path you want to enable.

 

<PageParserPaths>

  <PageParserPath VirtualPath=”/pages/test.aspx” CompilationMode=”Always” AllowServerSideScript=”true” />

</PageParserPaths>

 This is nothing new to most people, but it just popped up on one of our pages because someone had made changes to the web.config file.

Random Posts

Loading…

Leave a Reply