1

What is the difference between PageParserPath and SafeControl in the case of site pages?

Is both for allowing server side code for site pages?

PageParserPath

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

SafeControl

<Assemblies>
<Assembly Location="SampleToDeployAPage.dll"
          DeploymentTarget="GlobalAssemblyCache">
  <SafeControls>
    <SafeControl 
           Assembly="$SharePoint.Project.AssemblyFullName$" 
           Namespace="SampleToDeployAPage" 
           TypeName="MyPageTemplate" Safe="True"/>
  </SafeControls>
</Assembly>
</Assemblies>

2 Answers 2

2

Safe Controls - What does it mean?

A fundamental assumption of the Windows SharePoint Services technology is that "untrusted users" can upload and create ASPX pages within the system on which Windows SharePoint Services is running. These users should be prevented from adding server-side code within ASPX pages, but there should be a list of approved controls that those "untrusted" users can use. One way to provide these controls is to create a Safe Controls list.

The Safe Controls list is a list of controls and Web Parts specific to your SharePoint site that you have designated as safe for invocation on any ASPX page within your site. You store this list in the web.config file in your Web application root.

read more on safe control

PageParserPaths - what is it and when to use it

AS in the above answer, "Page parser path" is to allow inline code in asp.net. A good location to specify as a PageParserPath is the location where you store your masterpages, for example /_catalogs/masterpage. You can now add server side script to your masterpages, which makes it available in all pages using this masterpage.

ref

9
  • inline code means code added to the aspx file?
    – anish
    Oct 15, 2013 at 8:48
  • yes you are right. Fro Example: <head> <script type="text/c#" runat="server" > protected void Page_Load(object sender, EventArgs e) { // your here... } </script> </head><body></body> Oct 15, 2013 at 8:57
  • ok.If we are creating a site page is it a mandatory to add PageParserPaths ? Safe Controls?
    – anish
    Oct 15, 2013 at 9:02
  • Firstly, "PageParserPath" is an optional entry in the web.config. It is required only when you have some inline code on your page. Secondly, AFAIK, Safe Control entry is not required for site pages. However, Safe Control entry is required for Web parts and User Controls. Oct 15, 2013 at 9:08
  • In the link site pages i have seen, If the page is customized, server-side code does not run, and the page does not render. This includes the code-behind for the page itself.So server side code not supported in site pages?i mean .cs
    – anish
    Oct 15, 2013 at 9:13
1

SafeControls are to add controls contained in your own binaries to SharePoint.

Page parser path is to allow inline code in asp.net markup in page layouts for instance. i.e. stuff between <% and %> tags

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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