locked
How to solve Error SPSite - The Web application at <address> could not be found RRS feed

  • Question

  • Hello,

    I am trying to find out the internal name of a custom SharePoint list columns, for this I have used following code snippet in my
    console application but getting below error. The site I am accessing is a public SharePoint web site. This code is working
    well with my local host site and i am able to get the internal names of any list columns but don't understand why this is failing with
    public SharePoint site

    For avoiding this issue I have done following steps:

    1.Rebuild the application

    2.changed the  platform target as "Any CPU"

    3.Visual studio and this public site is working in my admin account, but still I am getting the error!

    I use visual studio 2010 and SharePoint 2010

    please note the error I am getting


    Error : The Web application at https://public.sp.a5-group.com/ 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

    Code Snippet

    static void Main(string[] args)
            { 
                using (SPSite Site = new SPSite("https://public.sp.a5-group.com/"))
                using (SPWeb web = Site.RootWeb)
                {
                    SPList splst = web.Lists["ListCard"];
                    foreach (var field in splst.Fields)
                    {
                        bool isHidden = splst.Fields[field.ToString()].Hidden;
                        if (!isHidden)
                        {
                            string internalName = splst.Fields[field.ToString()].InternalName; //This will give you the internal column name.
                            Console.WriteLine(internalName);
                        }
    
                    }
                    Console.ReadLine();
                }
    
            }
    

    Friday, March 21, 2014 5:53 AM

Answers

  • I thin you need to have sharepoint installed on same computer and URL should be working on this computer.

    If this URL WEB APP is in your IISsite try to create disableloopbackcheck registry which should be help

    When you use the fully qualified domain name (FQDN) or a custom host header to browse a local Web site that is hosted on a computer that is running Microsoft Internet Information Services (IIS) 5.1 or a later version, you may receive an error message 

    http://support.microsoft.com/kb/896861

    • Marked as answer by John Jos Monday, March 24, 2014 5:45 AM
    Friday, March 21, 2014 6:00 AM
  • hi

    check url in IIS manager (host header in site's bindings). The url which you used in the program may be public url while internal url may be different. And of course you need to run the program on the server from farm where accessed Sharepoint site is hosted.


    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

    • Marked as answer by John Jos Monday, March 24, 2014 5:45 AM
    Friday, March 21, 2014 11:17 AM

All replies

  • I thin you need to have sharepoint installed on same computer and URL should be working on this computer.

    If this URL WEB APP is in your IISsite try to create disableloopbackcheck registry which should be help

    When you use the fully qualified domain name (FQDN) or a custom host header to browse a local Web site that is hosted on a computer that is running Microsoft Internet Information Services (IIS) 5.1 or a later version, you may receive an error message 

    http://support.microsoft.com/kb/896861

    • Marked as answer by John Jos Monday, March 24, 2014 5:45 AM
    Friday, March 21, 2014 6:00 AM
  • hi

    check url in IIS manager (host header in site's bindings). The url which you used in the program may be public url while internal url may be different. And of course you need to run the program on the server from farm where accessed Sharepoint site is hosted.


    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

    • Marked as answer by John Jos Monday, March 24, 2014 5:45 AM
    Friday, March 21, 2014 11:17 AM
  • Dear Indrjeet,

    Thank you very much for giving me a useful answer. Let me check.

    • Marked as answer by John Jos Friday, March 21, 2014 11:38 AM
    • Unmarked as answer by John Jos Monday, March 24, 2014 5:46 AM
    Friday, March 21, 2014 11:36 AM
  • Dear sadomovalex,

    Thank you very much for answering me, it is very useful to me.

    • Marked as answer by John Jos Friday, March 21, 2014 11:38 AM
    • Unmarked as answer by John Jos Monday, March 24, 2014 5:46 AM
    Friday, March 21, 2014 11:38 AM
  • I know it's quite long time ago, but in my case, I have to do 2 things:
    1. gives access to config db, user is programmatically able to open SPSite-object
    Add-SPShellAdmin -username [domain]\[username]
    1. gives 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/

    • Edited by Kal Luu Wednesday, July 22, 2020 7:20 AM
    Wednesday, July 22, 2020 7:16 AM