I am running my ASP.NET application within the context of the SharePoint
environment. It is installed into the C:\Program Files\Common Files\Microsoft
Shared\web server extensions\12\TEMPLATE\LAYOUTS directory. I have SharePoint
Root site and sub-sites. I use FormDigest control and It seems that the problem
is with adding FormDigest control to the page. It works without any problem, If
I run my app from the Root Site or from a sub-site as a user who has at least
view permissions on the Root site.
If I run my app from a sub-site as a user who does not have permissions to the
Root Site, I get the error :
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at
Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAcce\
ssException ex)
at Microsoft.SharePoint.Library.SPRequest.RenderFormDigest(String bstrUrl,
ISPDataCallback pFormCallback)
at Microsoft.SharePoint.WebControls.FormDigest.RenderCore(SPWeb web)
at Microsoft.SharePoint.WebControls.FormDigest.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Here is the code how I add FormDigest control on the page:
protected void Page_Load(object sender, EventArgs e)
{
FormDigest formDigest = new FormDigest();
formDigest.ID = "formDigest";
Page.Controls.Add(formDigest);
}