Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Login form
Message
 
 
To
21/12/2013 13:15:16
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
ASP.NET
Category:
Other
Title:
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01590776
Message ID:
01590783
Views:
62
>Okay,
>
>My turn to prove how dense I can be. I'm brand new at MVC 4, but have worked in Silverlight for years so some of the concepts are the same. However, I have created a User view that contains a login form (simply user name / password and login button which does a submit.). On the home controller, I redirect the index action to the user controller for login if the user is not validated. I created a usercontroller to process the action, but my problem is that the login action is never hit. I've tried everything I can think of.
>
>Here's the user view:
>
>@model Xamlware.Models.Users
>
>@{
>    ViewBag.Title = "Log in";
>}
>
>
><h2>Use a local account to log in.</h2>
>@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
>    @Html.AntiForgeryToken()
>    @Html.ValidationSummary(true)
>
>    <fieldset>
>        <legend>Log in Form</legend>
>        <ol>
>            <li>
>                @Html.LabelFor(m => m.UserName)
>                @Html.TextBoxFor(m => m.UserName)
>                @Html.ValidationMessageFor(m => m.UserName)
>            </li>
>            <li>
>                @Html.LabelFor(m => m.Password)
>                @Html.PasswordFor(m => m.Password)
>                @Html.ValidationMessageFor(m => m.Password)
>            </li>
>        </ol>
>        <input type="submit" value="Log in" />
>    </fieldset>
>}
>
>
>
>
>Here's the user controller:
>
>
>    public class UserController : Controller
>    {
>
>        private IUsersRepository _userSRepository;
>
>        public UserController(IUsersRepository usersRepository)
>        {
>            _userSRepository = usersRepository;
>        }
>
>        public ActionResult Index()
>        {
>            return View();
>        }
>
>        [HttpPost]
>        public ActionResult Login()
>        {
>            return View();
>        }
>
>
>        [HttpPost]
>        public ActionResult Login(string userName, string password)
>        {
>            //if (ModelState.IsValid)
>            //{
>            //    var 
>            //    if (user.IsValid(user.UserName, user.Password))
>            //    {
>            //        FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
>            //        return RedirectToAction("Index", "Home");
>            //    }
>            //    else
>            //    {
>            //        ModelState.AddModelError("", "Login data is incorrect!");
>            //    }
>            ////}
>            
>            return View();
>        }
>    }
>
>
>Neither login method is hit when I place a break point there. Any help is definitely appreciated.

Both methods have HTTPPost attribute, I think one of them should be get instead.

Also, what is the name of your page? E.g. what is the URL?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform