TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
DEBESH ROY
NA
13
1.6k
Object reference not set to an instance of an object
Oct 5 2017 4:42 AM
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
Reply
Answers (
3
)
Search any record from Database
Add external dashboard in MVC4 project & and pass value.