public class CheckoutController : Controller
{
string userID;
public CheckoutController()
{
userID = User.Identity.Name;
}
...
}
When I run the above code, I get this error,
**Make sure that the controller has a parameterless public constructor.**
In that class, most of method need that userID, so I want to define that value in constructor, how can I solve this problem?
[Edit]
public class CheckoutController : Controller
{
string userID;
public CheckoutController()
{
//None
}
}
This code works fine, no error.

public CheckoutController(), but you would like to make use ofpublic CheckoutController(int userId)?