Solved

Code blocks are not allowed in SharePoint 2013

Posted on 2013-11-25
6
1,183 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 15

Expert Comment

by:Walter Curtis
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 15

Expert Comment

by:Walter Curtis
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

943 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

6 Experts available now in Live!

Get 1:1 Help Now