Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3593676
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:36:30+00:00 2026-05-18T19:36:30+00:00

I have a HomeController with an Index action that shows the Index.aspx view. It

  • 0

I have a HomeController with an Index action that shows the Index.aspx view. It has a username/password login section. When the user clicks the submit button, it POSTs to a Login action in the AccountController.

        <% Html.BeginForm("Login", "Account", FormMethod.Post); %>

In that action, it tests for Username/Password validity and if invalid, sends the user back to the Login page with a message that the credentials were bad.

    [HttpPost]
    public ActionResult Login(LoginViewModel Model, string ReturnUrl)
    {
        User user = MembershipService.ValidateUser(Model.UserName, Model.Password);
        if (user != null)
        {
            //Detail removed here
            FormsService.SignIn(user.ToString(), Model.RememberMe);
            return Redirect(ReturnUrl);
        }
        else
        {
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
        }
        // If we got this far, something failed, redisplay form
        return RedirectToAction("Index", "Home");  // <-- Here is the problem.  ModelState is lost.
    }

But here’s the problem: the ValidationSummary is always blank because we’re losing the Model when we RedirectToAction.

So the question is: How do I send the user to the action on a different controller without a Redirect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T19:36:31+00:00Added an answer on May 18, 2026 at 7:36 pm

    As others have said it’s common to return the view if validation fails but as you are calling from your account controller you will want to specify the full path of your view

    return View("~/Views/Home/Index.aspx", model);
    

    Or

    It is also common to have a seperate login page and redirect to that page if the login fails. Both pages will submit to the same login action. Facebook does this for example.

    Or

    As you only want to display an error message

    return RedirectToAction("Index", "Home", new { LoginAttempts = 1 });
    

    then in your Index action read the LoginAttempts parameter and choose to display the error message accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MVC3 Razor view which has a link that requires user login
If I have a HomeController displaying its Index view, how would I proceed in
On my HomeController I have an index action which redirects to the index action
Actually im doing a home page that only have an action called Index() that
I have parent view that also renders sub-controller action using RenderAction() (that returns a
I have the following code in my HomeController's Index action, and the code below
I have the following action: public class HomeController : Controller { public ActionResult Index(int?
I have deleted public/index.html. Here is my config/routes.rb Those all I have in that
In my ASP.Net MVC app, I have the following controllers HomeController ExController ExController has
I have an ASP MVC3 application that has several HttpPost ActionResult methods. During a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.