The Web application at URL 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.


Here is another very important post based a problem which made me pull my hairs and after wasting 5 working days, I was able to find a solution.

When accessing SPSite object from a web application we get this error.

The Web application at URL 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.

Since, we cannot code in client object model (because of security issues) therefore, this was a blocking issue.

Piece of code which is creating problem:

SPSite aSite = newSPSite(“URL”);

 Steps to reproduce:

  1. Just create and empty web site project in VS 2010.
  2. Add SharePoint’s DLL reference.
  3. Add the above code page.
  4. Run the site

 Solutions which are available on internet:

  • Running the web application in 64-bit mode.
  • Changing to target framework to 3.0 instead of 4.0
  • Adding app pool identity user to WSS_ADMIN_WPG
  • Adding app pool identity user to Administrator group

 Error we get:

The Web application at URL 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.

One-liner solution summary: The app pool identity of the web-service and your SharePoint portal must be the same.

 Detailed solution: (in my case it was a web-service so I am posting my solution related to that)

  1. Create an empty folder on your favourite location using Windows file explorer
  2. Create an empty IIS website in IISManager (Run à inetmgr)
  3. While creating this new website in IIS it will ask for the physical path – Give it the same folder path which you created in step 1
  4. Click on test connection to make sure IIS has permission to this folder
  5. Next to Site name textbox there is Application Pool section. There is a ‘select’ button next to it – Just click it
  6. From this new dialog box select the application pool of your SharePoint site (This is MUST)
  7. Click OK and then change the port to any available port
  8. Run your development environment (in my case Visual Studio 2010) as administrator
  9. Go to your web-service project –> Right click and publish –> Select file system –> From target location’s text box click browse –> Select local IIS and select your website.
  10. Select radio button ‘Delete all existing files prior to publish
  11. Click Open à then click publish
  12. Open browser and go to localhost:portnumber (portnumber you gave in step 7)

 To debug: In order to debug your code in this published web-service attach it to all w3wp (worker process) instances J

I hope it will help you all save your precious time and hairs on the head :D

Happy SharePointing ;-)

Advertisements

6 Comments

  1. developper

    thank you!!!!i love you so much!!!!!!!!!!!!!!! you are my herooooooooo

  2. John

    Set the 64-bit mode, solve the problem.

  3. developper

    not true i have tried this 64 bit thing but it doesn’t work! only muneeb’s solution worked for me

  4. Prabu

    fantastic.. worked like a charm

  5. Dinesh

    “One-liner solution summary” did the trick for me. I had also same setup; webservice and sharepoint separate application pool. I assigned sharepoint site pool to webservice and it worked. Many thanks Ahmed!!

  6. Wonderful !!! You saved me lots of time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: