3
votes

I have an application page that I am creating in SharePoint to host in the LAYOUTS directory. The page inherits from LayoutsPageBase, and has no other code right now. The ASPX file is set to inherit from this class/assembly. Pretty straightforward.

My problem is that I want to deploy my assembly to the application BIN directory (not GAC) and use a CAS permission policy to allow it to execute within SharePoint. However, at this point, whenever I deploy the page I get this exception:

Request failed. at System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase) at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError) at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly) at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)

In every other case in which I've gotten permissions errors, the exception has indicated which specific permission I was missing (e.g. SqlClientPermission or FileIOPermission).

I know that the issue is CAS-related, as it works fine when I deploy to the GAC.

My current CAS permissions look like this:

      <PermissionSet class="NamedPermissionSet" version="1" Name="MyPermissionSet">
        <IPermission class="AspNetHostingPermission" version="1" Level="Minimal" />
        <IPermission class="SecurityPermission" version="1" Flags="Execution, SkipVerification, UnmanagedCode, ControlEvidence" />
        <IPermission class="Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" version="1" Unrestricted="True" ObjectModel="true" />
        <IPermission class="System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
        <IPermission class="System.Data.OracleClient.OraclePermission, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
      </PermissionSet>

My current thinking is that it's related to the LayoutsPageBase class, as the page works fine with my CAS policy when I change it to inherit from a basic System.Web.UI.Page.

I used the permcalc tool available from Microsoft on my assembly and added the permissions that it discovered, but the issue was not resolved.

So my long-winded question is this: has anyone ever deployed application pages that inherit from SharePoint's LayoutsPageBase using CAS policies, and what permissions did you need to specify in your CAS policy to get it to work?

2

2 Answers

2
votes

Ok, figured this out. The LayoutsPageBase class of the Microsoft.SharePoint.WebControls namespace is decorated as follows:

[PermissionSet(SecurityAction.InheritanceDemand, Name="FullTrust"), PermissionSet(SecurityAction.LinkDemand, Name="FullTrust")]
public class LayoutsPageBase : UnsecuredLayoutsPageBase

So the upshot is that you have to have full trust (either by way of the GAC or a permission set membersihp) to run an application page that inherits from LayoutsPageBase.

0
votes

Did you try to deploy the assembly to the _app_bin instead of the bin folder ?