Solved

Code blocks are not allowed in SharePoint 2013

Posted on 2013-11-25
6
1,157 Views
Last Modified: 2014-11-26
I have a inline server side code running in master pages and couple of aspx pages running in web root folder of SharePoint web application.
This is a sharepoint 2013 web application migrated from sharepoint 2010.
i had this working in sharepoint 2010 by adding the page parser value like this

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

and selective pages addition in same page parser.

Now when i do the same addition in page parser it does not work in sharepoint 2013.

IF i modify the page parser with this entry it works
<PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />

which opens the whole pages for scripting and it is not acceptable in our environment.

i tried to run the scripting in the specific pages also but until i open the whole master-page folder it is not working

this does not works

<PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />      
        <PageParserPath VirtualPath="/CustomPages/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
        <PageParserPath VirtualPath="/fillname.aspx" CompilationMode="Always" AllowServerSideScript="true" />

this works
<PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />      
        <PageParserPath VirtualPath="/CustomPages/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
        <PageParserPath VirtualPath="/fillname.aspx" CompilationMode="Always" AllowServerSideScript="true" />

but this is not acceptable to open scripting in all pages.

I am kind of confused what is the new settings in SharePoint 2013. is there a way to run scripting in specific location only.

what will happen if we open scripting in the root file. isn't it in secured and open for scripting

any suggestions please...
0
Comment
Question by:kukdai
  • 3
  • 2
6 Comments
 
LVL 14

Expert Comment

by:SneekCo
ID: 39677844
This is not a suggested solution because you have probably run across this yourself, but I had the same problem in 2010 and this link help me solve the problem.

http://social.technet.microsoft.com/Forums/en-US/sharepointadminprevious/thread/10b9dce5-db29-48e3-be4a-102f5b54535b/


Good Luck
0
 
LVL 9

Author Comment

by:kukdai
ID: 39679147
Thanks for the comment,
but looks like you did not read it properly. this is not a 2010 web application it is 2013.
I know how it works in 2010 but the same way it is not working in 2013 and i don't know why.
adding page parser to specific page or to master page folders doesn't help in 2013 anymore unless you all scripting in all the pages inside your web application.
0
 
LVL 14

Expert Comment

by:SneekCo
ID: 39679222
Too bad it was not something that could help. I did read it correctly, and as I mentioned the solution for me was in a 2010 farm. But thought it was worth a few key strokes to try to help.

Hope you find your solution soon.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Expert Comment

by:Alexander Sviridov
ID: 40316665
Problem in Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.IsExcludedPath(string virtualPath) method. This method use static field SPRequestModule.s_excludedFileList. This field initiated in SPRequestModule.Init metod.
BUT method Microsoft.SharePoint.ApplicationRuntime.SafeModeConfigurationHandler.Create(), which use SPRequestModule.IsExcludedPath called before SPRequestModule.Init

1. create custom configuration handler class

public class MySafeModeConfigurationHandler : IConfigurationSectionHandler
    {
        public object Create(object parent, object configContext, XmlNode section)
        {
            var type = typeof(Microsoft.SharePoint.ApplicationRuntime.SPRequestModule);
            var field = type.GetField("s_excludedFileList", BindingFlags.Static | BindingFlags.NonPublic);
            object s_excludedFileList = field.GetValue(null);
            if (s_excludedFileList == null)
                field.SetValue(null, Activator.CreateInstance(field.FieldType));

            type = Type.GetType("Microsoft.SharePoint.ApplicationRuntime.SafeModeConfigurationHandler, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
            var method = type.GetMethod("Create");
               
            object o = Activator.CreateInstance(type);
            object result = method.Invoke(o, new object[]{parent, configContext, section});

            return result;
        }
    }
2. change web.config

      <!--section name="SafeMode" type="Microsoft.SharePoint.ApplicationRuntime.SafeModeConfigurationHandler, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /-->
      <section name="SafeMode" type="MyNamespace.MySafeModeConfigurationHandler, MyLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=fc475d95eb56414f" />
0
 
LVL 9

Accepted Solution

by:
kukdai earned 0 total points
ID: 40457357
I never got a good solutions for this problem.
0
 
LVL 9

Author Closing Comment

by:kukdai
ID: 40466448
I never got a good and appropriate solution for the problem..
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now