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 9188213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:57:06+00:00 2026-06-17T19:57:06+00:00

Upon successful validation of the form, I’m unable to redirect the form. Please help

  • 0

Upon successful validation of the form, I’m unable to redirect the form. Please help me. I’m very new to ASP.NET and MVC Concepts.
I have given below the model, the view and the controller. The Index page displays login information, and I’m submitting the form to the same page. If there are no errors, I have to redirect the form to a different page. This is what I’m trying to do. But even If I provide valid login information, the form doesn’t redirect to the specified page.

Model

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace MyProject.Models
{
  public class LoginModel
  {  
    [Required(ErrorMessage = "UserCode is Required.")]
    public string UserCode
    {
        get;
        set;
    }

    [DataType(DataType.Password)]
    [Required(ErrorMessage = "Password is Required.")]
    public string Password
    {
        get;
        set;
    }
  }
}

Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MyProject.Models;

namespace MyProject.Controllers
{
[HandleError]
  public class HomeController : Controller
  {
    // GET
    public ActionResult Index()
    {
        return View();
    }

    // POST
    [HttpPost]
    public ActionResult Index(LoginModel model)
    {
        if (ModelState.IsValid)
        {
            RedirectToAction("Transfer", "Home");
        }

        return View(model);
    }

    public ActionResult UpgradeBrowser()
    {
        return View();
    }
  }
}

View

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"   Inherits="System.Web.Mvc.ViewPage<MyProject.Models.LoginModel>" %>


<div id="LoginBox">
<% using (Html.BeginForm("Index", "Home", FormMethod.Post, new { id = "FrmLoginUser" }))
   { %>
    <table class="TblForm">
        <tr>
            <td><label for="UserName">UserCode</label></td>
            <td><%= Html.TextBox("UserCode", "", new { id = "UserCode" })%></td>
            <td><%= Html.ValidationMessage("UserCode", new { @class = "ValidationError" })%></td>
        </tr>
        <tr>
            <td><label for="Password">Password</label></td>
            <td><%= Html.Password("Password", "", new { id="Password" })%></td>
            <td><%= Html.ValidationMessage("Password", new { @class = "ValidationError" })%></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" value="Login" /></td>
        </tr>
    </table>
<% } %>

</div> <!-- #LoginBox -->
  • 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-06-17T19:57:07+00:00Added an answer on June 17, 2026 at 7:57 pm

    You have to actually return the result of the RedirectToAction call. Change RedirectToAction to be return RedirectToAction in your controller HttpPost method:

    [HttpPost]
    public ActionResult Index(LoginModel model)
    {
        if (ModelState.IsValid)
        {
            return RedirectToAction("Transfer", "Home");
        }
    
        return View(model);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Asp.Net MVC project with the typical forms authentication that redirects the
Net MVC 3.0 Project I have a form in my page and a Ajax.ActionLink
I am a newbie when it comes to ASP.NET MVC so it would be
I am having problems with MVC RC2 where upon validation failure, the failed field
I am writing a transaction page whereby upon a successful transaction, the user is
Upon reviewing a bunch of MVC style web applications, I'm noticing that it's common
I'm writing an application that do some task and inform user upon successful completion
I have this html: <div id=signbtn> <a id=login-link class=btnsignin title=Login>Sign in</a> </div> Upon successful
I'm having a problem with a site where I'm using the ASP.NET SQL Membership
Upon successful login, I'm saving the session variable. When the user goes to different

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.