Solved

Code blocks are not allowed in SharePoint 2013

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

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 17

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
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

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.

Question has a verified solution.

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

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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