Click here to Skip to main content
13,197,548 members (49,946 online)
Rate this:
Please Sign up or sign in to vote.
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.

[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 (
                  //  return RedirectToAction("Display", "Home");
               // }
               // here I would like to code to show the data of the one who logged in with Edit, delete options
                ModelState.AddModelError("", "EmailId or Password Incorrect.");
        return View(model);
Posted 7-Nov-12 22:09pm
Updated 7-Nov-12 22:20pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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

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:[^]
Dorababu743 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100