I am connecting to SharePoint via managed client api. ClientContext connects to the site and access the list data when I specify the site address as http://computer_name but when I give the configured alternate access mapping like http://demo.somedomain.com, I end up with 401 Unauthorized exception.

Both computer name and alternate mapping works without problems when I use the browser to access the site.

PS: I am trying to access the site over the internet.

Any help is appreciated.

  • Did you find a solution for this? I do not get 401, but keep getting "Cannot contact site at specified url". I'm connecting to sharepoint site via hostheader web app url.
    – vasya10
    Dec 22, 2011 at 5:27

3 Answers 3


This could be the infamous loopbackcheck error. When accessing a site through a host header other than the actual machine name, asp.net will throw a security error.More info here:

You receive error 401.1 when you browse a Web site that uses Integrated Authentication and is hosted on IIS 5.1 or a later version


The issue here is that you are accessing the resource from a FQDN. Service calls happen outside of the explorer security zones and use winHTTP, as such it interprets single name as intranet and forwards credentials and FQDN as Internet and prompts... In an unattended scenario this means the call fails as unauthorized.

Solution is to add th FQDN to the AuthForwardServerList registry entry as per this article: http://support.microsoft.com/kb/943280


I think this is what you are looking for:


The authentication method for the Client Object Model for Office 365 is a little different than the authentication for on-premise SharePoint environment. Thats the reason you might be getting the 401 error.

  • I know this solution but unfortunately this solution is far from being functional in the context of a service application. It is impossible to do authentication on behalf of users. Jul 26, 2011 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.