Error: The Web application at http://[URL to SharePoint]/ could not be found?

Basant B. Pandey
  • Error: The Web application at http://[URL to SharePoint]/ could not be found? Basant B. Pandey

    I have googled it but am unable to find the correct answer to this problem. Below is my code that I used in my development server. Please tell me the exact solution related to that problem:

    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.

    using (SPSite _Site = new SPSite("http://demo2010a:8082/sites/Test2"))
        using (SPWeb _Web = _Site.OpenWeb())
            foreach (SPList list in _Web.Lists)
                if (count <= 4)
                    string listLink = "<a  href='" + list.DefaultView.Url.ToString() + "'>" + list.Title + "</a>(<b>" + list.Items.Count + "</b>)<br>";
                    linksHtml += listLink;

  • How is your code executed? Webpart? Feature? CLI?

    Is there some other way to open the site collection, such as Context?

    If not, have you tried opening the root site collection first, and then try your Test2 site collection?

  • please check the alternate access mappings in cenztral administration. The URL must be configured. Maybe your created the application with host header and the AAM is not what your are using in your code. If you confired the iis site manualy sharepoint "may" seem to work correct, but unless AAM is configured it is only working somehow :-)

    SO check your AAM and see if http://demo2010a:8082 is there. FQDN is something different... etc. It must match. No SSL, etc. Exact match :-)

    Using the object model seems to use the URL to access it via HTTP, but all it does is making a SQL query to the database to see if the HOST part of your URL is a valid AAM entry.

    Ciao Marco

    AAM Link: http://<>/_admin/AlternateUrlCollections.aspx

    PowerSHell test code: [System.reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) $site = new-object Microsoft.SharePoint.SPSite("http://demo2010a:8082/sites/Test2")

error development
Related questions and answers
  • I'm have some trouble using the GetList web service. It does work sometimes but not at the start of the day!?! Here is my code: public static void ListSurveys(string serverName... information using GetList. I use the List GUID as the list name. An exception is thrown. The SOAP body is shown below. &lt;?xml version="1.0" encoding="utf-8"?> &lt;soap:Envelope xmlns:soap="http... because my code had fetched the GUID of the list just milliseconds earlier! Can anyone explain what is going on here? I had the same problem yesterday and at some point it just went away

  • I have a Silverlight 4 Beta application where I'd like to use the SharePoint object model to upload a document to a SharePoint site - should be simple enough, except an exception is thrown at: using (SPSite siteCollection = new SPSite(siteCollectionUrl)) The Web application at could not be found. Verify that you have typed the URL correctly. If the URL... isn't in the IIS metabase because it's being handled by DNS. My web application has an AAM set up and a host header on the web site in IIS. I also tried running the code without using the FQDN

  • Has anybody upgraded an old custom field type to use the new XSL transform in SharePoint 2010? I have a multi-column field type, and want the Display pattern to render the 2nd "column", which..., but that ends up rendering the actual anchor tag, as opposed to a clickable hyperlink: &lt;a href="">;/a> So then I tried creating a XSL transform, since that is supposed to be the new and improved way of doing this. Unfortunately, I can't get that to work either. I am getting the same thing I got using the RenderPattern. I'm no XSL expert, so can anyone

  • I'm trying to create a site collection via stsadm. I do: STSADM -o createsite ` -url "&lt;url>" ` -title "&lt;title>" ` -description "&lt;desc>" ` -lcid 1033... as to how to fix this problem? (Just to note, I created a web application via stsadm with the same user credentials and that worked fine.) ..., at the Powershell prompt I get only the following output: User cannot be found. If I look into the ULS logs, I see the following related logs (truncated a bit for clarity): Creating site http

  • I'm trying to add a custom web part (that is one I have written myself) using the new Javascipt OM available with SharePoint 2010. My solution is also running within the Sandbox. I have it working correctly for the Content Editor Web Part (based on sample code), however when I replace the Content Editor Web Part definition with one for my own web part I get the following error... --------------------------- Things I have tested: I can successfully upload my .webpart definition to the web part gallery, and the web part works. I can successfully add the web part to the page

  • I have a webpart i build using WSpBuilder and it works OK. When i use Deploy from Visual Studio it installs the WSP sharepoint and add the webpart to the webpart gallery. But it seems the feature...(SPFeatureReceiverProperties properties) { SPSite site = null; try { site = properties.Feature.Parent as SPSite; using (SPWeb web = site.RootWeb...(".")); // delete web parts that have been added if (webpartName == "myStoreComms") { list.Items[i].Delete(); break

  • ), the list form suddenly works correctly. This makes me think there's something wrong with my content type. Here's what I'm working with. Some names have been changed to protect the innocent. &lt;ContentType.... Scoped to Site. Registration: contains a ListTemplate and a ListInstance that just modifies a basic Custom List to enable content types and add my custom content type. Scoped to Web. Here's what's happening. When I activate ContentTypes, the content type and field are deployed as expected into my site collection. When I activate Registration, the list is provisioned and the content type is added

  • I have a standard website (one Web Application and one Site Collection) with some custom pages and webparts. The issue I'm having is that when I try to switch users, using the "Sign In As a Different User" and entering new credentials (even for another Site Collection admin account), IE tries the account three times, and then it presents a 401 Access Denied screen. After that, if I erase all the stuff of access denied page from the browser's url, I'm logged as the new account I just had entered and was not accepted. After researching for a while on google, I found a KB ( http

  • Full disclosure: Sharepoint development noob. I currently have 3 custom web parts built in an SP solution in VS2010. I build and deploy my project out to our local Sharepoint dev box. However, after...="" > &lt;Module Name="Home" List="113" Url="_catalogs/wp"> &lt;File Path="Home\Home.webpart" Url="Home.webpart" Type="GhostableInLibrary" > &lt... xmlns="" > &lt;Module Name="IdeaGrid" List="113" Url="_catalogs/wp"> &lt;File Path="IdeaGrid\IdeaGrid.webpart" Url="IdeaGrid.webpart" Type

Data information