odata - wcf data services - passing extra params on save changes -
I have an existing web application that I want to wrap with WCF data services, giving it an audacity input / output formatting .
In recovering the records, send me whatever you like (myusername = "blabala", mycurrentusersession = "23434sdfgdf" and so on ...). But I do not control what I've sent in "Save Change" - however, I need the ability to supply an existing application: - My current user session - Recover the key of the specific state (My existing app is static)
You can add these values to the heading of outgoing requests.
Suppose you have " , then search for and then, and inside In the data context of the WCF-DataService, which you can easily process on server end. You can service reference " in your Client app, your
WCF-DataService .
Reference.cs client inside the service),
OnContextCreated event:
SendingRequest event
Add a handler in partial Zero onContextCreated () {this.SendingRequest + Entity_SendingRequest; }
Entity_SendingRequest you can add the header.
Zero Entity_SendingRequest (Object Sender, SendingRequestEventArgs e) {e.RequestHeaders Add ("myusername", "blabala"); E.RequestHeaders.Add ("mycurrentusersession", "23434 sdfgdf"); }
CookieContainer . This is the basis of form authentication for WCF-data services.
Zero Entity_SendingRequest (Object Sender, SendingRequestEventArgs E) {CookieContainer cookieContainer = new CookieContainer (); Forac (_cookies in var cc) {cookie cookie = new cookie (cc.Key, cc.Value.Value); Cookie Container Add (new urie ("http: // localhost", urchx.zolute), cookie); } Var cookieHeader = cookieContainer.GetCookieHeader (new urie ("http: // localhost", Urickind. Absolute)); E.RequestHeaders ["cookie"] = cookie header; }
Comments
Post a Comment