title: Placing MVC 4 login control on Home/index page
body: <p>First off I am new to MVC, I was a webforms guy...</p>
  
  <p>I want to show my login control on my <code>home/index</code> page, but no matter what I do I run in to errors.  I have tried various techniques and have gotten many errors with each technique, so I wont list them all here.</p>
  
  <p>Right now I have it set that if <code>Request.IsAuthenticated</code> then show the username else show the login form.  But the form is obviously looking at the home controller and nothing happens when I submit the login.</p>
  
  <p>Any advice would be much appreciated. I have been dabbling for days on this.</p>
  
  <p>Thanks :)</p>
  
  <p>Here is the Code:</p>
  
  <pre><code>'@{
  ViewBag.Title = "MyApp";
  }
  
  &lt;p&gt;Code for main Index Page here&lt;/p&gt;
  
  
  @model Application.Models.LoginModel
  @{
  ViewBag.Title = "Log in";
  }
  
  @if (Request.IsAuthenticated) {
  &lt;text&gt;
      Hello, @Html.ActionLink(User.Identity.Name, "Manage", "Account", routeValues:     null, htmlAttributes: new { @class = "username", title = "Manage" })!
      @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) {
          @Html.AntiForgeryToken()
          &lt;a href="javascript:document.getElementById('logoutForm').submit()"&gt;Log off&lt;/a&gt;
      }
  &lt;/text&gt;
  } else {
  
  
  &lt;section id="loginForm"&gt;
  &lt;h2&gt;Use a local account to log in.&lt;/h2&gt;
  @using (Html.BeginForm(new { ReturnUrl = "RedirectToAction" }))
  {
  @Html.AntiForgeryToken()
  @Html.ValidationSummary(true)
  
  &lt;fieldset&gt;
      &lt;legend&gt;Log in Form&lt;/legend&gt;
      &lt;ol&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.UserName)
              @Html.TextBoxFor(m =&gt; m.UserName)
              @Html.ValidationMessageFor(m =&gt; m.UserName)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.LabelFor(m =&gt; m.Password)
              @Html.PasswordFor(m =&gt; m.Password)
              @Html.ValidationMessageFor(m =&gt; m.Password)
          &lt;/li&gt;
          &lt;li&gt;
              @Html.CheckBoxFor(m =&gt; m.RememberMe)
              @Html.LabelFor(m =&gt; m.RememberMe, new { @class = "checkbox" })
          &lt;/li&gt;
      &lt;/ol&gt;
      &lt;input type="submit" value="Log in" /&gt;
  &lt;/fieldset&gt;
  &lt;p&gt;
      @Html.ActionLink("Register", "Register", "Account") if you don't have an account.
  &lt;/p&gt; 
  }
  @section Scripts {
  @Scripts.Render("~/bundles/jqueryval")
  }
  &lt;/section&gt;
  }
  </code></pre>
  
  <p>'</p>