I have the following model:
public class AccountDetailsViewModel
{
public Guid ID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
Then I have AccountController with followign action
public ActionResult Details(Guid? id)
{
var model = new AccountDetailsViewModel
{
ID = 2,
FirstName = "FirstName",
LastName = "LastName"
};
return View(model)
}
And strongly type view for this action
@model AccountDetailsViewModel
...
@Html.ActionLink("My Page", "Details", "Account")
...
//display info about user
The idea is that when user access Account/Details url without id parameter his own info is displayed, and when id is present in the url info about user with that id is shown.
The problem is that when user access url with id (someone's other page), the link My Page(on the top of the view) points to the same page. ActionLink takes id of the currently displayed user, and this is a problem, as I want My Page link always point to Account/Details (to my page). This id for ActionLink is not taken from @Model as I thought first, it look like there is some other magic which i am not fammiliar with.
The same problem I have with other pages.
So what is going on and how to prevent this type of behaviour?