tags:

views:

202

answers:

2

I'm trying to add simple login page to ASP.NET MVC app. I actually use Sharp Arch template project. So, I added 3 methods Login(), Logout(), and DoLogin() to UsersController, where Login() just does return View("Login");

Now, when I navigate to /Users/Login, my aspx is displayed with submit button:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage" Title="Login" %>
<%@ Import Namespace="Orders.Web.Controllers" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<h2>Login</h2>
    <% if (ViewContext.TempData["message"] != null){ %>
        <p><%= ViewContext.TempData["message"]%></p>
    <% } %>
    <% using (Html.BeginForm<UsersController>(u => u.DoLogin()))
       { %>
            <div><% =Html.SubmitButton("submit") %></div>
    <% } %>
</asp:Content>

However, when I click Submit, request is made once again to Login() - I can see it when I set breakpoint there, it doesn't try to go to UsersController.DoLogin() even though in resulting HTML page form has action /Users/DoLogin. When I manually enter /Users/DoLogin in browser, it gets called and my breakpoint gets fired.

I'm banging my head for few hours already... I don't see whats wrong here.

A: 

Must be a routing issue. Can you paste your routes, you could also try this route debugger

redsquare
OK I tried the debugger, /Users/Login and /Users/DoLogin both route to appropriate controller/action... actually both /Users/Login and /Users/DoLogin works as expected when typed into URL in browser. It's the submit button that seems to fail to work...
queen3
A: 

OK, so thanks to jamesshannon I found that this was because my site.master page suddenly wrapped everything into an ASP.NET form - probably because I edited it using VS2008 editor. Not sure if such behavior is very nice but... now I'm aware.

queen3