SharePoint error: Web application at xxxx could no

2019-04-18 14:19发布

When I try to execute this code:

SPSite siteCollection = new SPSite(@"http://sp-devxxx:10000/");

It throws the following error:

The Web application at http://sp-devxxx:10000 could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

I can hit this site from my web browser, it is compiling in x64, my account has read/write access to the content db, the code is running on the server that the site is running on and there exists an access mapping for this site. Why would it be throwing this error?

13条回答
姐就是有狂的资本
2楼-- · 2019-04-18 14:22

I have a Web API on the SharePoint server that we use as a medium to get data from our own database. This Web API was attempting to open the website, and I was receiving the same error. I had to make sure that the Application Pool identity being used had access to open the website.

I set the identity of the Web API application pool to SharePointServerFarm, which is the identity that my SharePoint web applications use.

查看更多
SAY GOODBYE
3楼-- · 2019-04-18 14:23

Try Logging on as the Farm Admin account. Or, granting the required SQL Server Roles to the account you are using.

查看更多
Anthone
4楼-- · 2019-04-18 14:30

Change Target Platform to x64 as Sharepoint 2010 runs only in 64 bit mode

查看更多
Rolldiameter
5楼-- · 2019-04-18 14:32

OK, after hours of pain i finally found the problem....

I had to add myself to the WSS_ADMIN_WPG group on the server. Hope this helps someone.

查看更多
小情绪 Triste *
6楼-- · 2019-04-18 14:32

Add-SPShellAdmin -UserName domain\username did the trick for me. The documentation says that it adds user to the SharePoint_Shell_Access role in the farm configuration database only, and also ensures the user is added to the WSS_Admin_WPG local group on each server in the farm.

查看更多
Juvenile、少年°
7楼-- · 2019-04-18 14:36

The account that is the identity of the app pool in my environment was already a member of WSS_ADMIN_WPG. I installed my web service locally. Using the external domain name such as

SPSite siteCollection = new SPSite(@"http://mydomain:123");

failed, reporting the same error as the poster (even though it is reachable from a browser on the same machine). The following worked

SPSite siteCollection = new SPSite(@"http://localhost");

I have yet to figure out why.

查看更多
登录 后发表回答