0

I am upgrading a site to MVC 4 and the new simplemembership is killing me.. I am not sure if I am just being stupid but I cannot seem to get UserName from a stored UserId.

In mvc 3 with asp membership I used the following in Razor views where item.CreatedBy is stored Guid:- "@Membership.GetUser(item.CreatedBy).UserName"

What is the equivalent Razor syntax to work with SimpleMembership when itemCreatedBy is now an int.

I am trying to do something like :- @GetUserNameFromId(item.CreatedBy)

All help and pointers gratefully accepted.

many thanks for your time and help

Glyn

  • you can even use aspnet membership provider in MVC4, thats what I did when I upgraded my project from MVC2 to MVC4. – Niraj Dec 17 '12 at 11:31

1 Answers1

2

By default, MVC 4 uses SimpleMembership which is not compatible with the older MembershipProvider. If you haven't modified the Account controller & models, you could try to copy it from a fresh MVC 3 app and replace the existing ones in MVC 4 and see if that helps. Here's a link I found useful from geekswithblogs.net

merlot
  • 194
  • 3
  • 11