Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all I am new to MVC3 have written a code for login using MVC3 architecture every thing works fine, now I would like to display the user information after he logs in. How can I develop the code in MODEL , I would like to get the results with out using linq and Enity framework.

SQL
[HttpPost, ValidateInput(false)]
    public ActionResult LogOn(Login model)
    {
        if (ModelState.IsValid)
        {
            if (model.IsUserExist(model.EmailId, model.Password))
            {
               ViewBag.UserName = model.EmailId;
              //I tried this which didn't worked
                 //if (model.select(model.EmailId))
                //{
                  //  return RedirectToAction("Display", "Home");
               // }
               // here I would like to code to show the data of the one who logged in with Edit, delete options
            }
            else
            {
                ModelState.AddModelError("", "EmailId or Password Incorrect.");
            }
        }
        return View(model);
    }
Posted
Updated 7-Nov-12 22:20pm
v2

1 solution

If you're using Forms authentication, you should be able to use FormsAuthentication.SetAuthCookie:

http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.setauthcookie.aspx[^]

And when you redirect to home using return RedirectToAction("Display", "Home"), your Display view can use HttpContext.Current.User.Identity.Name to display the name:

http://msdn.microsoft.com/en-us/library/system.web.httpcontext.user.aspx[^]
 
Share this answer
 
Comments
demouser743 8-Nov-12 4:16am    
I would like to display all the results not just user name or some thing. I would like to display in grid format with edit and delete options
jim lahey 8-Nov-12 4:19am    
In fairness, your original question didn't say anything about a grid and edit and delete options. If you do want CRUD functionality, then I'm afraid you are going down the Linq and Entity Framework road.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900