I am getting this error as I am trying to display user details from sql server after login
This is my action method:
public ActionResult ViewProfile(string id)
{
var user = db.user1.SingleOrDefault(u => u.UserName == id);
return View(user);
}
My .cshtml view:
UserID:@Model.UserID
UserName:@Model.UserName
UserEmail:@Model.UserEmail
I am getting the error "Object reference not set to an instance of an object" in this view
This is my link in view clicking on which i can view user profile:
@Html.ActionLink("Profile", "ViewProfile", "Home", new { id = User.Identity.Name})
My Model:
public partial class user1
{
public int UserID { get; set; }
public string UserEmail { get; set; }
public string UserName { get; set; }
public string UserPassword { get; set; }
} This model is derived from sql server
Please help
DEBESH ROYPosted Oct 5, 2017, 11:05 AM
ViewProfile
@Html.ActionLink("Click here","Index","Home")
@Html.ActionLink("Profile", "ViewProfile", "Home", new { id = user1.UserName })
@Html.ActionLink("logout", "LogOff", "Home")
Ramesh PalanivelPosted Oct 5, 2017, 7:32 AM
Ramesh PalanivelPosted Oct 5, 2017, 7:29 AM