
Hi Jerry,
I have sorted it out. the main cause is some orphan sites in DB. so when I extract all sites the error message comes up. I modified my source code and the error has gone.
Thanks
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi there,
Today I ran into a problem is to deploy a custom application page in the SharePoint Farm (One is Application Server, another is WFE). When we access the custom application page, we got the following error: File not found. I am sure the *.aspx lives in the _layouts hive so the whole URL will be https://xxx.xxx.xxx/_layouts/15/somefolder/x.aspx. the code was installed in other SharePoint Farms are Standalone and work well. Finally, when we access the application page, I found out something wrong (401 Unauthorized) by IE [F12]
Does anyone have any idea on this problems?? Thanks
source code:
SPSecurity.RunWithElevatedPrivileges(delegate ()
{
SPFarm sPFarm = SPFarm.Local;
foreach (SPService sPService in sPFarm.Services)
{
if (sPService is SPWebService)
{
SPWebService sPWebService = (SPWebService)sPService;
foreach (SPWebApplication sPWebApplication in sPWebService.WebApplications)
{
foreach (SPSite sPSite in sPWebApplication.Sites)
{
Response.Write(sPSite.RootWeb.Title + "</br>");
}
}
}
}
});
Hi Jerry,
I have sorted it out. the main cause is some orphan sites in DB. so when I extract all sites the error message comes up. I modified my source code and the error has gone.
Thanks
@Will ,
For "File not found", I suggest you could double check if the application page is hosted in /layouts folder like below:
For 401 Unauthentication, did this happen for the whole application page or just the code snippet ? And what's the detailed request occured the 401 error ?
for testing the path of custom application layout page you may also copy regular text file (test.txt - with some test text inside so it won't be empty) to the same folder c:\program files\common files\microsoft shared\Web Server Extensions\15\Template\Layouts\somefolder and then request it by url: https://xxx.xxx.xxx/_layouts/15/somefolder/text.txt. In this case ASP.Net pipeline won't be used and text file should be returned as is. If it won't be returned then most probably there is some problem in used url.
If it will be returned - then path is valid. In this case ensure that assembly with codebehind for your page is installed to the GAC on WFE. If it is installed - try to temporary comment out all codebehind in your page and re-install assembly to the GAC (in order to test if codebehind causes File not found error).
Hi @Will ,
Please remember to accept your own post above as answer if the problem is resolved so that it could help others in the forum.