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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:12:16+00:00 2026-05-16T23:12:16+00:00

What pattern can I use to display errors on an MVC 2 view that

  • 0

What pattern can I use to display errors on an MVC 2 view that are not related to a single property?

For example, when I call a web service to process form data, the web service may return an error or throw an exception. I would like to display a user-friendly version of that error, but have no logical means to relate the error to any given property of the model.

UPDATE:

Trying to use this code as suggested, but no summary message is displayed:

MyPage.spark:

Html.ValidationSummary(false, "Oopps it didn't work.");

Controller:

ViewData.ModelState.AddModelError("_FORM", "My custom error message.");
// Also tried this: ViewData.ModelState.AddModelError(string.Empty, "My custom error message.");
return View();

UPDATE 2

What does this mean?

next to each field.

Instead of always displaying all
validation errors, the
Html.ValidationSummary helper method
has a new option to display only
model-level errors. This enables
model-level errors to be displayed in
the validation summary and
field-specific errors to be displayed
next to each field.

Source: http://www.asp.net/learn/whitepapers/what-is-new-in-aspnet-mvc#_TOC3_14

Specifically, how does one add a model level error (as opposed to a field-specific error) to the model?

UPDATE 3:

I noticed this morning that Html.ValidationSummary is not displaying any errors at all, not even property errors. Trying to sort out why.

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

    Simply adding a custom error to the ModelState object in conjunction with the ValidationSummary() extension method should do the trick. I use something like "_FORM" for the key… just so it won’t conflict with any fields.

    As far as patterns go, I have it setup so that my Business Logic Layer (called via services from the controller) will throw a custom exception if anything expected goes wrong that I want to display on the view. This custom exception contains a Dictionary<string, string> property that has any errors that I should add to ModelState.

    HTHs,
    Charles

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

Sidebar

Related Questions

In a swing GUI application, where MVC pattern is applied, how can we use
I know that I can pass object values through a URL pattern and use
What is a design pattern I can use for generating context-sensitive right click menus
Is there a pattern, Xml structure, architecture technique we can use to create simple
Can I use sed if I need to extract a pattern enclosed by a
Is there a pattern that can handle recurring dimension in data warehouse? I've got
How can I match a pattern in regex that can contain anything (letters,numbers,...) but
How can I implement the so called repository pattern that Rob Conery shows in
I'm using jax-rs (jersey) to create a website / web-service that other users can
Here is the example code from my web.xml <security-constraint> <display-name> change password</display-name> <web-resource-collection> <web-resource-name>change

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.