Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to pass data from DelegatingHandler to Controller in ASP.NET Web API?

I'm implementing an authorization related DelegatingHandler where I load-up the api user (caller) profile from database. When the authorization is successful I'd like to pass this instance to the controller otherwise I'd must load it again.

Is there any way to do this without using session or rely on repository cache?

like image 663
fredzvt Avatar asked May 07 '13 12:05

fredzvt


Video Answer


1 Answers

The HttpRequestMessage class contains a dictionary "Properties" that you could use to store that information. However, I am not sure if it is get persisted between the handler invocation and the controller action. Otherwise, you can try with an action filter where the action context is already created. The action context gives you access to the action arguments, where you can add an additional argument to be passed to the action.

like image 172
Pablo Cibraro Avatar answered Oct 05 '22 07:10

Pablo Cibraro