2

Problem could be reproduced for all types of Client Model Object (Managed, JS, etc..)

for example (Managed Client Model Object):

using (var context = new ClientContext("http:\\WebApplicationURL"))
{
    var site = context.Web;
    context.Load(site, s => s.Title);
    context.ExecuteQuery();
    Console.WriteLine(site.Title);
    Console.ReadLine();
}

1) All works fine if cookies is turned on in web.config for Web Application ()

in "fiddler":

Request: POST /_vti_bin/client.svc/ProcessQuery HTTP/1.1

Response: HTTP/1.1 200 OK

2) If using cookieless session ()

"context.ExecuteQuery()" generate WebException "The remote server returned an error: (404) Not Found."

in "fiddler":

Request: GET /(S(1j0bsz55e3dk1455dhagx4ry))/_vti_bin/client.svc/ntlm/ProcessQuery HTTP/1.1

Response: HTTP/1.1 404 Not Found

What settings should be applied for correct working "Client Model Object" in cookieless session or "Client Model Object" couldn't be used without cookies at all?

EDIT

Some additional problems description:

  1. with cookies context.ExecuteQuery() transform in 4 requests (all requests/response aren't contains cookies) (

    • 3 calls to /_vti_bin/sites.asmx requesting the FormsDigest information, which contains the security token.
    • 1 to /_vti_bin/client.svc/ProcessQuery

    Request: POST WebApplication/_vti_bin/client.svc/ProcessQuery HTTP/1.1 X-RequestDigest: 0xECF432C8EB314A8C6B5ED6AB71466996B36E554AC51D445633AA8D038FCD9CB410A6965E6D0F33D6AF70F273D05510F55C1AD37089648F1EE5317A3B0F194EFE,30 Jan 2014 13:50:00 -0000 Content-Type: text/xml X-RequestForceAuthentication: true Host: WebApplication Content-Length: 612 Expect: 100-continue

    Response: HTTP/1.1 200 OK Cache-Control: private Content-Type: application/json Server: Microsoft-IIS/7.5 SPRequestGuid: ea3f7a0b-2170-413a-8e42-9d2b1e56fcde X-SharePointHealthScore: 0 X-Content-Type-Options: nosniff X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET MicrosoftSharePointTeamServices: 14.0.0.7015 X-MS-InvokeApp: 1; RequireReadOnly Date: Thu, 30 Jan 2014 13:50:00 GMT Content-Length: 273

    [ { "SchemaVersion":"14.0.0.0","LibraryVersion":"14.0.7010.1000","ErrorInfo":null },2,{ "IsNull":false },4,{ "IsNull":false },5,{ "ObjectType":"SP.Web","ObjectIdentity":"740c6a0b-85e2-48a0-a494-e0f1759d4aa7:web:622c751b-aedf-4185-9737-f0768a64142d","Title":"sc1718" } ]

  2. without cookies: context.ExecuteQuery() transform in 5 requests (all requests/response aren't contains cookies)

    • 3 calls the same as "with cookies"
    • 2 calls to _vti_bin/client.svc/ntlm/ProcessQuery

    1) Request: POST WebApplication/_vti_bin/client.svc/ProcessQuery HTTP/1.1 X-RequestDigest: 0xF71F2826979622452C5DDE5F3A1D55BC3B7EAD70E0798452D1F47A74242CC92A76F5DC84209CECE798F2F93735CCC41527714C2DE58113194962843BB065BF98,30 Jan 2014 09:44:22 -0000 Content-Type: text/xml X-RequestForceAuthentication: true Host: WebApplication Content-Length: 612 Expect: 100-continue

    Response: HTTP/1.1 302 Found Content-Type: text/html; charset=utf-8 Location: /(S(zvjwtkawdkuozwfurptxk245))/_vti_bin/client.svc/ntlm/ProcessQuery Server: Microsoft-IIS/7.5 SPRequestGuid: 1229be02-6a64-4f31-bb21-fc91f1d10bd8 X-SharePointHealthScore: 1 X-Powered-By: ASP.NET MicrosoftSharePointTeamServices: 14.0.0.7015 X-MS-InvokeApp: 1; RequireReadOnly Date: Thu, 30 Jan 2014 09:44:21 GMT Content-Length: 195

    Object moved

    Object moved to here.

2) Request: GET WebApplication/(S(zvjwtkawdkuozwfurptxk245))/_vti_bin/client.svc/ntlm/ProcessQuery HTTP/1.1 X-RequestDigest: 0xF71F2826979622452C5DDE5F3A1D55BC3B7EAD70E0798452D1F47A74242CC92A76F5DC84209CECE798F2F93735CCC41527714C2DE58113194962843BB065BF98,30 Jan 2014 09:44:22 -0000 Content-Type: text/xml X-RequestForceAuthentication: true Host: share1:1718

Response: HTTP/1.1 404 Not Found Cache-Control: private Content-Type: text/html; charset=UTF-8 Server: Microsoft-IIS/7.5 SPRequestGuid: c1e7007a-d866-446d-add5-ea4dee2cba0e X-SharePointHealthScore: 1 X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET MicrosoftSharePointTeamServices: 14.0.0.7015 X-MS-InvokeApp: 1; RequireReadOnly Date: Thu, 30 Jan 2014 09:44:21 GMT Content-Length: 1019

#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px} Service Service


Endpoint not found.

1

you need cookies as its used for form autentication:

The FormsAuthenticationLoginInfo class is used by the ClientContext.FormsAuthenticationLogin method by first calling the EnsureLogin method to check for authentication cookies.

more detailed info can be found here: goto Authentication section!

http://www.codeproject.com/Articles/268193/SharePoint-2010-Client-Object-Model-Part-1

taken from link above from fiddler you can see where its setting the cookie authentication in bold

HTTP/1.1 200 OK

Cache-Control: private

Content-Type: application/json

Server: Microsoft-IIS/7.5

SPRequestGuid: 22e3f795-a5c9-492d-a551-3e950b8f1c10

Set-Cookie: WSS_KeepSessionAuthenticated={4e4cffb3-203e-4857-8f5a-90a4b18789a4}; path=/

X-SharePointHealthScore: 0

X-Content-Type-Options: nosniff

X-AspNet-Version: 2.0.50727

X-Powered-By: ASP.NET

MicrosoftSharePointTeamServices: 14.0.0.6029

Content-Length: 460

EDIT

Ok so now i know your using windows authentication you need to send the credentails using the following:

clientContext.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;

FormsAuthenticationLoginInfo formsAuthInfo = new FormsAuthenticationLoginInfo("MyUser", "MyPassword");

clientContext.FormsAuthenticationLoginInfo = formsAuthInfo;

in your case:

using (var context = new ClientContext("http:\\WebApplicationURL"))
{
    context.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
    FormsAuthenticationLoginInfo formsAuthInfo = new FormsAuthenticationLoginInfo("MyUserName", "MyUserPassword");
    context.FormsAuthenticationLoginInfo = formsAuthInfo;
    var site = context.Web;
    context.Load(site, s => s.Title);
    context.ExecuteQuery();
    Console.WriteLine(site.Title);
    Console.ReadLine();
}

or anonymous user:

using (var context = new ClientContext("http:\\WebApplicationURL"))
{
    context.AuthenticationMode = ClientAuthenticationMode.Anonymous;
    var site = context.Web;
    context.Load(site, s => s.Title);
    context.ExecuteQuery();
    Console.WriteLine(site.Title);
    Console.ReadLine();
}

http://msdn.microsoft.com/en-us/library/office/ee535729(v=office.14).aspx

EDIT 2

lol your not making it easy!

using (var context = new ClientContext("http:\\WebApplicationURL"))
{
    context.Credentials = new NetworkCredential("userName", "Userpassword", "domain");
    var site = context.Web;
    context.Load(site, s => s.Title);
    context.ExecuteQuery();
    Console.WriteLine(site.Title);
    Console.ReadLine();
}
  • I use windows authentication. – Dmitry Prikhodko Jan 30 '14 at 13:36
  • just ammended my answer! – Ali Jafer Jan 30 '14 at 14:13
  • Unfortunately "Forms Authentication" is disabled for the site on IIS – Dmitry Prikhodko Jan 30 '14 at 14:21
  • have you tried the anonymous user method?> – Ali Jafer Jan 30 '14 at 14:58
  • Yes: The remote server returned an error: (401) Unauthorized. – Dmitry Prikhodko Jan 30 '14 at 14:59
0

I think authentication is wrong way for investigation, because all requests for getting the FormsDigest information (which contains the security token) are identical with or without cookies. Problems with rediraction:

 -> POST WebApplication/_vti_bin/client.svc/ProcessQuery 
 <- HTTP/1.1 302 Found Content-Type: text/html; charset=utf-8 Location: /(S(zvjwtkawdkuozwfurptxk245))/_vti_bin/client.svc/ntlm/ProcessQuery

and second request on the url is failed:

 -> GET WebApplication/(S(zvjwtkawdkuozwfurptxk245))/_vti_bin/client.svc/ntlm/ProcessQuery
 <- HTTP/1.1 404 Not Found

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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