I have a strange problem in the ManageUser/EditUser part of the site.
I'm building the site from scratch, using a different layout, but so far, the Controller and Model code is identical with the original site. The code in the EditUser and ManageUser Views is 100% identical.
When I press the "Edit user" link on the ManageUser View, I get the
"System.NullReferenceException: Object reference not set to an instance of an object"
error in the EditUser View.
I ran the debugger, and I can see that, when I press the ""Edit user" link on the ManageUser View, the EditUser Action is called, but the "id" parameter is empty, which means the MembershipUser object will be null. So, the Model which is passed to the EditUser View is null, and the Veiw can't write any values from the Model, hence the NullReferenceException.
When I hover the mouse over the EditUser link, I can see the correct path, with the correct querystring parameter, in the status line in the lower left corner of the browser:
In the EditUser Action, if I hardcode the id parameter to ex. "Admin", like this:
[Authorize(Roles = "Admin")]
public ActionResult EditUser(string id)
id = "Admin";
ViewData["roles"] = (String)Roles.GetAllRoles();
MembershipUser membershipUser = Membership.GetUser(id);
ViewData["PageTitle"] = "Edit " + id;
- it works, and the EditUser View is displayed correctly.
So, it seems like the querystring parameter isn't passed to the EditUser Action.
I'm running the site using Cassini, but the original site runs perfectly on Cassini, so this shouldn't be the reason...