开发者

SharePoint error: Web application at xxxx could not be found

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?


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.


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


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.


In a console application using visual studio 2012 it was changing the Target framework to 3.5 for me....


In my case, I re-opened Visual Studio 2012 running as Administrator, and the problem is solved.


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.


In case the user's account is already a member of WSS_ADMIN_WPG and still the issue persists, As mentioned by Tim.

Try the following steps:

  1. Go to Project Properties
  2. Build Tab
  3. Change the Platform Target value to Any CPU from the drop down.

It resolved the problem for our console Application.


Have you disabled the loopback check?

http://sptwentyten.wordpress.com/2010/03/06/disable-the-loopback-check-via-powershell/

http://www.jeremytaylor.net/2010/05/24/sharepoint-disable-loopback-check-disableloopbackcheck-dword-in-registry/


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


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.


In my case, I needed to add the user db_owner permission to the SharePoint_Config, SharePoint_AdminContent and WSS_Content databases, following the suggestions in this blog.


I know this is an old and answered thread, but none of the above worked for me, and here's what did for future reference:

I have a windows forms application creating an instance of a sharepoint 2013 site and gives the mentioned error when trying to initialize the SPSite, after some search I've found the following reference that suggests (among other possible resolutions) the issue could happen when running the code on a machine different than the one running the actual Site, and yes it worked flawlessly when I moved the app to the other machine.

I know this is not a radical solution, but at least you know the issue.

reference:

Common issue: new SPSite API call returns "The Web application at http://server:port/ could not be found."


Had the same issue while running my code as "exe" file. Problem solved by running cmd as administrator. Hope this help someone.


I know it's quite long time ago, but in my case, I had to do 2 things:

  1. give access to config db, user is programmatically able to open SPSite-object
Add-SPShellAdmin -username [domain]\[username]
  1. give access to content db, user is programmatically able to open SPWeb-object
Add-SPShellAdmin -username [domain]\[username] -database [content db guid]

You can get the Guid of content db by running following Get-SPContentDatabase -webapplication [web application url]

You can find here the original answer of Timo Pitkäranta: https://blog.stefan-gossner.com/2011/09/18/common-issue-new-spsite-api-call-returns-the-web-application-at-httpserverport-could-not-be-found/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜