Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET MVC3
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 (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 7-Nov-12 23:09pm
Edited 7-Nov-12 23:20pm
v2

1 solution

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

Solution 1

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[^]
  Permalink  
Comments
Dorababu743 at 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 at 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
0 DamithSL 265
1 CPallini 235
2 OriginalGriff 233
3 Maciej Los 195
4 George Jonsson 170
0 OriginalGriff 5,305
1 DamithSL 4,382
2 Maciej Los 3,760
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,901


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 8 Nov 2012
Copyright © CodeProject, 1999-2014
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