get current logged in userID in aspnet mvc membership 



حمایت از ما | مشهدهاست

get current logged in userID in aspnet mvc membership


حمایت از ما | مشهدهاست

حمایت از ما | مشهدهاست حمایت از ما | مشهدهاست

حمایت از ما | مشهدهاست
`

get current logged in userID in aspnet mvc membership




i am trying to show a list of users of my application "school", when admin logs in then he can view all the users in list but when school principals logins, he should get only users of his school, So i thought to get the current loggedIn userId first and then by that userId i'll get schoolId since userId is foreign key in school table...once i'll get the schoolId i can show the members of that school.

But my problem is how to get the UserID of currently loggedIn. I'm using MVC 1.0 Asp.Net -- "Membership"

if my logic above is wrong then please tell me the alternate good idea, so that principal can see only his users list..




1:


The Simple Solution With the scenario you describe you would only be able to do this by retrieving the User information with the data stored in the HttpContext.Current.Identity. For example, if the HttpContext.Current.Identity.Name is the Username, then you would use that value to retrieve the User data for the principal that should include the UserId you can use to locate the appropriate school.

Alternate Solution You might consider storing the SchoolId in the user's profile so that it is more easily accessible.




 اين مطلب بدون دخالت انساني عينا از اين آدرس کپي شده و تمامي مسوليت آن با ناشر اصلي است.

How to get current page URL in MVC 3
Why is access to the path denied?
Login failed for user 'IIS APPPOOL\ASP.NET v4.0'
How to call javascript function from code-behind
ASP.NET Web Application Message Box
IE9 JavaScript error: SCRIPT5007: Unable to get value of the property 'ui': object is null or undefined

How to write a simple Html.DropDownListFor()?
What is the right way to populate a DropDownList from a database?
A potentially dangerous Request.Path value was detected from the client (*)
Download/Stream file from URL - asp.net
Unable to update the EntitySet - because it has a DefiningQuery and no <UpdateFunction> element exist
IIS Express enable external request
*