1

We are using SP2013, and have created an application page (policy.aspx), deployed via VS into layouts folder. Our environment has 1 web app with multiple site collections. The policy page should be accessible to all users.

At moment we have hardcoded the path of the policy page to sitecol1_layouts\test\policy.aspx and notice that suppose USER A tries to access this page from sitecol1 then he can access because he is member of this site col. However, if User B (member of sitecol2) tries to access this path then he gets error, however, a solution to this is to dynamically generate the current site URL and then appends the _layouts\test\policy.aspx to it.

Now, this works, I want to know if this is the only solution.

1

/_Layouts/ represents the physical path and is accessible from any site / site collection. So if you are using Javascript client object model it can be retrieved using SP.Utilities.Utility.getLayoutsPageUrl . Example:

var pageUrl = SP.Utilities.Utility.getLayoutsPageUrl('/SharePointRibbonDemo/RibbonDemo.aspx')

In server side this can be retrieved using SPUtility.GetGenericSetupPath("TEMPLATE\\LAYOUTS")

2
  • Is this the only solution? Was my question.
    – variable
    Apr 25 '14 at 7:15
  • There may be other ways as well, but I find this to be nice way of doing it instead of hard coding or doing some unnecessary string manipulations and concatenations Apr 25 '14 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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