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 " service reference " in your Client app, your WCF-DataService .

, then search for Reference.cs client inside the service), OnContextCreated event:

and then, SendingRequest event

  Add a handler in partial Zero onContextCreated () {this.SendingRequest + Entity_SendingRequest; }   

and inside 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"); }   

In the data context of the WCF-DataService, which you can easily process on server end.

You can 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

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -