asp.net web api - Cookie changes made in EndRequest are not sent in Response -


I have a logic that revises the cookies in the endRequest method and it is in the webform and MVC Works perfectly 1 .

But I have just figured out that it does not work in WebApi, even if it looks like this.

When I set up a webapp method MyMethod , if the method sets the cookie, I see it in response. But even if the fire and sets after the EndRequest , the desired cookie will be Does not are sent in the request. It seems that you can not modify the response code in Andrequest , but I do not understand why and what to do about it.

Can anyone tell me what is happening here, and what to do about it so that I can run my essential logic without calling it clearly in every web method? If I need to modify the response, then what is the correct way to capture the intention of EndRequest within WebApi?


[1] It is not directly relevant to this question, but the reason is that I grab the values ​​of cookies and add a hash key to the cookie Can I cook cookies against I give the argument to protect cookies from endRequest , in my app code, whatever I want with cookies and can secure everything once I know that I All changes of the material have been done with biscuits.

endquest is the last event in the pipeline that can be executed. It is called after the response is sent. You can not use it to manipulate the reaction.

  Public class MyHttpMessageHandler: DelegatingHandler {protected async override}      Task & LT; HttpResponseMessage & gt; SendAsync (HttpRequestMessage request, cancellation token cancellation token) {// Request something with the request ... // // // Request request var response = await the base. SendAsync (request, cancellation token); // Do something with feedback ... ... feedback; }}  

You will then need to register it

  Global Configuration. Configuration. Message Holders Add (New HTTP Message Handler ());  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -