none
SPSite site = new SPSite -- The Web application at http://mysite/ could not be found.

    Question

  • I used to run the following line to call up a web site and it worked perfectly fine (when I run the exe, I run locally on all the servers) and the mysite will simply be the server name of server where I am running from

     

     

    using (SPSite site = new SPSite(http://mysite))

    Now, I have a different servers that are setup for nlb. And the above line no loner work. I have tried in on all the front end servers and app server by using just the server name won't work. Is that something to with the settings? Please advice

    And here my error.

    The Web application at http://mysite/ 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.

    Thursday, August 19, 2010 6:35 PM

Answers

  • It is a window application. I used to run this sucessfully in a SharePoint server when there is no NLB

    Now, I use this same window application, but in a NLB environment, I've tried running on the 2 front servers, or the application servers, but none of them work. Any suggestion?

     

    Hi wkpli,

    I would take a multistep approach.  1st check to see if you can access the site from within a browser using the URL.

    If you can, then go into Central Administration and add some Alternate Access Mappings (AAM) entries.  You haven't stated that you had tried this approach yet. 

    Read more about AAM here  

    - Xenox G.

    • Edited by Xenox Sunday, August 22, 2010 2:13 AM added link to alternate access mappings
    • Marked as answer by wkpli Monday, August 23, 2010 4:39 PM
    Sunday, August 22, 2010 2:11 AM

All replies

  • Is your Absolute URL in the Alternate Access Mapping?

    Check the following link :

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsite(office.12).aspx

    The first post by Rodney Viana describes this issue.

     

    -Xenox G.

     

    Thursday, August 19, 2010 8:06 PM
  • Hi wkpli,

    Thanks to share your problem.

    Try this:

    string Myurl = SPContext.Current.Web.Url;

    using (SPSite siteCollection = new SPSite ( Myurl ));

    Please let me know if it works


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"
    Friday, August 20, 2010 5:27 AM
    Moderator
  • Nope, it doesn't work. I got the following error:

    string Myurl = SPContext.Current.Web.Url; <-- Object reference not set to an instance of an object

     

    And I tried using http://computername.domain.intra, it is not working either, I got the same error message.

    Friday, August 20, 2010 1:28 PM
  • Where are you running this code from?  Is it from a Console Application?

    Is it being run on one of the web front end servers?

     

    If you already tried adding an Internal Alternate Access Mapping, try adding an Internal Alternate Access Mapping with the IP address of your NLB.

    - Xenox G.

    Friday, August 20, 2010 9:46 PM
  • It is a window application. I used to run this sucessfully in a SharePoint server when there is no NLB

    Now, I use this same window application, but in a NLB environment, I've tried running on the 2 front servers, or the application servers, but none of them work. Any suggestion?

     

    Sunday, August 22, 2010 1:17 AM
  • It is a window application. I used to run this sucessfully in a SharePoint server when there is no NLB

    Now, I use this same window application, but in a NLB environment, I've tried running on the 2 front servers, or the application servers, but none of them work. Any suggestion?

     

    Hi wkpli,

    I would take a multistep approach.  1st check to see if you can access the site from within a browser using the URL.

    If you can, then go into Central Administration and add some Alternate Access Mappings (AAM) entries.  You haven't stated that you had tried this approach yet. 

    Read more about AAM here  

    - Xenox G.

    • Edited by Xenox Sunday, August 22, 2010 2:13 AM added link to alternate access mappings
    • Marked as answer by wkpli Monday, August 23, 2010 4:39 PM
    Sunday, August 22, 2010 2:11 AM
  • Hi,

    1. Make sure you run the windows application from the server (The SharePoint 2007 API cannot be used from remote location).
    2. Try to run this code with the 'System Account' (farm administrator) of your SharePoint server.

    Hope this will help,

    Eran Hefer,
    My Blog .

     

    Monday, August 23, 2010 5:14 AM
  • Thanks, it is working now, I added my front end server to the AAM.
    Monday, August 23, 2010 4:40 PM