0

I am building a RESTful API with the .net MVC Web API framework, and want to store some user information that comes in for updates/saves.

I am using an authorization attribute that authorizes based on tokens. When a valid token is seen, I want to grab that user's information from the database, and store the user object to be used inside the controller.

Is there an easy way to do this? It looks like in the regular .net MVC you would just store the user in the HttpContext. That seems to no longer exist though.

2 Answers 2

0

You can do custom parameter binding to the user object, by using an User object in the action parameter and registering a custom binder that will know how to handle that.

See here how to do parameter binding with Web API: http://blogs.msdn.com/b/jmstall/archive/2012/04/16/how-webapi-does-parameter-binding.aspx

Sign up to request clarification or add additional context in comments.

Comments

0

In the RC, you can get information about the current user through the ApiController's User property:

http://msdn.microsoft.com/en-us/library/system.web.http.apicontroller.user(v=vs.108)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.