开发者_开发知识库
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this questionIn my project once the user logs in they are assigned to an office and based on their office they only get information within that office. I want to get the current id of the user after logging in but i am not sure how to go about that or where to look. Any help or suggestions would be great.
asp.net mvc project.
Regardless of your data store, you could use a similar approach to @Omar's answer in this question I asked some time ago.
The basic idea is to define a parent/base Controller class from which all your relevant controllers inherit. Then, upon initializing that controller:
protected override void Initialize(RequestContext requestContext) { }
You would setup the data based within the office. I can't describe this much further, because you haven't provided a lot of specifics, but within Controller.Initialize
you would access this information via AD, your database, etc.
Finally, you could incorporate the retrieved data (via Repositories, etc) into your view models, or pass to the view using ViewData or ViewBag. Though, I recommend the former over the latter in the interest of code cleanliness.
精彩评论