asp.net mvc - Is it a good idea to pass IdentityUser object to other controller from View? -
in primary controller action method following current applicationuser object (it inherits identityuser):
[authorized] ... var user = await (usermanger<..>)usermanager.getuserasync(httpcontext.user)
the object need in view, pass viewdata:
viewdata["user"] = user;
in view want display auxiliary information current user:
@{ applicationuser user = (applicationuser)viewdata["user"]; int unreadmessages = othercontroller.gettotalunreadmsgs(user); }
therefore need applicationuser object in view. pass method of other controller. method uses dbcontext information db (context object scoped, single per request).
question: safe? exist better practice?
Comments
Post a Comment