Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Authentication Issue in MVC 4

$
0
0

I have code for successful Login,Here is my code

Note: I am using my own membership Provider,I am not using its own membership class

 if (ModelState.IsValid)
            {
                if (user.IsValid(user.Email, user.Password))
                {
                    FormsAuthentication.SetAuthCookie(user.Email, true);
                    return RedirectToAction("Index", "TestValidUser");
                }
                else
                {
                    ModelState.AddModelError("", "Login data is incorrect!");
                }
            }

I have this simple class/Model

 [Key]
 public int Id { get; set; }
 public string Email { get; set; }
 public string Password { get; set; }
 public string RoleName { get; set; }

Now i have two questions

  • I want to get UserId of Currently Login user
  • I want to check RoleName of logedin user


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>