How did you add requestheader from sendrequestevent if there is CookieContainer? I actually tried to add auth cookie into requestheaders manually for each odata request, but my my wcf dataservice seems cannot get login user infomration. the following steps
is what I did.
create WCF Data service AuthenticationService.svc and change to
and publish this service as basichttp binding. I also configure all web.config properly and global.ascx createtocken event.
Create my WCF data
service to expose my entity stuff
On my windows phone
project, add authentication service through "add service" and was able to create a login screen to call authentication service successfully. I also got token which sent from server side.
got Odata2 client
library and generate proxy class file. add tokent which I got from previous step and attach to OData service call by following statement
public partial class TestDBEntities : global::System.Data.Services.Client.DataServiceContext
partial void OnContextCreated()
this.SendingRequest += new EventHandler<System.Data.Services.Client.SendingRequestEventArgs>(TestDBEntities_SendingRequest);
private void TestDBEntities_SendingRequest(object sender, System.Data.Services.Client.SendingRequestEventArgs e)
if (String.IsNullOrEmpty(App.AuthToken) == false)
e.RequestHeaders["ASPXAUTH"] = App.AuthToken;
the problem is my WCF data service which host entity stuff doesn't have login user information and isauthenticated property is false. I also add [RequiresAuthentication] in
my service class. when I call HttpContext.Current.User.Identity.IsAuthenticated, it always show false and username is empty.
Did you know which steps I miss? Any comments will be appreciated.