Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Connecting To SharePoint Very Slow

Connecting To SharePoint Very Slow

Scheduled Pinned Locked Moved C#
helpsharepointsysadmindebuggingtutorial
2 Posts 2 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    I have this block of code

    try
    {
    _clientContext = new ClientContext(baseUrl);
    _clientContext.Credentials = new SharePointOnlineCredentials(userName, Password.GetSecureString(password));
    _clientContext.Load(_clientContext.Web, w => w.ServerRelativeUrl);
    _clientContext.ExecuteQuery();
    }
    catch (Exception e)
    {
    throw;
    }

    The code stops for about 20-25 seconds on the ExecuteQuery line. If I paste the URL into a browser it loads quicly, so I know that's not the problem. No error is thrown. It's just really slow. All subsequent calls to the server after that are ok. It's on this first calls that is really slow. Can anyone shed some light on this? I'm not really sure how to debug this.

    In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.

    P 1 Reply Last reply
    0
    • K Kevin Marois

      I have this block of code

      try
      {
      _clientContext = new ClientContext(baseUrl);
      _clientContext.Credentials = new SharePointOnlineCredentials(userName, Password.GetSecureString(password));
      _clientContext.Load(_clientContext.Web, w => w.ServerRelativeUrl);
      _clientContext.ExecuteQuery();
      }
      catch (Exception e)
      {
      throw;
      }

      The code stops for about 20-25 seconds on the ExecuteQuery line. If I paste the URL into a browser it loads quicly, so I know that's not the problem. No error is thrown. It's just really slow. All subsequent calls to the server after that are ok. It's on this first calls that is really slow. Can anyone shed some light on this? I'm not really sure how to debug this.

      In theory, theory and practice are the same. But in practice, they never are.” If it's not broken, fix it until it is. Everything makes sense in someone's mind.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Use Fiddler[^] to check the traffic you are sending out on the first call. My suspicion is that the slow first call is because it's trying to hit the msoid endpoints, which don't exist so you are waiting for the connections to time out. The next call knows that these don't exist so it avoids them. The fix is to change your hosts file to set these connections to your loopback address so that fails straightaway. Fiddler will identify what these domains are for you.

      Advanced TypeScript Programming Projects

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups