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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:01:15+00:00 2026-05-27T23:01:15+00:00

I have a question about ModelState and validation error messages in MVC3. I have

  • 0

I have a question about ModelState and validation error messages in MVC3.
I have in my register view the @Html.ValidationSummary(false) that shows me the DataAnnotations error messages from my Model object. Then.. in my Register action controller i have the ModelState.IsValid, but inside that if(ModelState.IsValid) i have another error controls that add to the modelstate with ModelState.AddModelError(string.Empty, "error...") and then I do a RedirectToAction, but the messages added in the ModelState doesn’t show at all.

Why this is happening?

  • 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-27T23:01:16+00:00Added an answer on May 27, 2026 at 11:01 pm

    and then i do a RedirectToAction

    That’s your problem. When you redirect the model state values are lost. Values added to the modelstate (including error messages) survive only for the lifetime of the current request. If you redirect it’s a new request, therefore modelstate is lost. The usual flow of a POST action is the following:

    [HttpPost]
    public ActionResult Foo(MyViewModel model)
    {
        if (!ModelState.IsValid)
        {
            // there were some validation errors => we redisplay the view
            // in order to show the errors to the user so that he can fix them
            return View(model);
        }
    
        // at this stage the model is valid => we can process it 
        // and redirect to a success action
        return RedirectToAction("Success");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and
I have question about database optimizing, indexing. I have table that called projects and
Refreshing the ModelState Hi, I have a question about the ModelState in an ASP.NET
Good day I have question about displaying html documents in a windows forms applications.
Have a question about full text search. I have a query that works, but
https://stackoverflow.com/a/64983/468251 - Hello, I have question about this code, how made that working with
I have question about normalization. Suppose I have an applications dealing with songs. First
I have a question about using streams in .NET to load files from disk.
I have a question about best practices regarding how one should approach storing complex
I have a question about locking. This doesn't have to be only about record

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.