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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -