Deploy files to _layouts folder in SharePoint 2013 and provide anonymous access


Below Sample code is to provide anonymous access to Custom files deployed under _layouts folder

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace Help.Layouts.Feature
{
    public partial class Help : UnsecuredLayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string pagesource;
            pagesource = Request.QueryString["q"].ToString();
            Response.Write(pagesource);

            Response.Write("<object id=\"embeddedhtml\" type=\"text/html\" data=\"http://servername/sample.txt\" width=\"100%\" height=\"100%\"></object>");

        }
        protected override bool AllowAnonymousAccess { get { return true; } }
    }
}

Happy coding ......Cheers .. Ajith

 


Comments (0)

Skip to main content