SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I couldn't use javascript on my page, have "Code blocks are not allowed in this file". I added

    <PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />    

into C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config on my Server, by nothing changed. Help plz, what's the problem?

share|improve this question
where is the page located? Master Page gallery? – Falak Mahmood Feb 21 '12 at 8:37

Are you trying to use <script/> blocks with the runat attribute set to true - which means that the script should be executed on the server side, or are you trying to just do client side JavaScripts?

If it is the first one, I strongly discourages you to do it this way. Allowing code blocks like this and modifying the web.config file to allow it is opening your farm up for all kinds of vulnerabilities and performance degradation. There is a reason for this being prohibited by default. If you really need code running in the pages, make a real codebehind solution. That is create a class deriving from Page (or any of the SharePoint derivatives).

If it's the latter case, remove the runat="true" attribute on your script tags.

share|improve this answer

If you're using Master Page Gallery, please use


share|improve this answer

Use the following code if your Page layouts are located in the Master Page Gallery.

        <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" />
share|improve this answer
No, I try to use Code at custom aspx page, not at master page. – kamax70 Feb 21 '12 at 10:50
it will work if your page layouts are existing in Master page gallery – Falak Mahmood Feb 21 '12 at 11:47
or is your page layout located in Layouts folder? – Falak Mahmood Feb 21 '12 at 11:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.