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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:39:39+00:00 2026-06-10T09:39:39+00:00

So I am trying to do get the key for a model object in

  • 0

So I am trying to do get the key for a model object in the controller so that I can add a AddModelError to it.

In my view I use

@Html.ValidationMessageFor(model => model.Email)

Whats the equivalent code to get the Key name to add in the controller so it attaches to this ValidationMessage.

  • 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-10T09:39:41+00:00Added an answer on June 10, 2026 at 9:39 am
    ModelState.AddModelError("Email", "the email is invalid");
    

    But usually that’s not something you should be doing manually in your controller but you should be using a validator. For example you could decorate this Email property with some validation data annotation attribute or if you are like me use FluentValidation.NET => this way you shouldn’t be asking yourself questions about keys but focus on the actual validation logic.

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

Sidebar

Related Questions

I'm trying to use my debug keystore so I can get a key for
I was trying to get a Model object from datastore using the key passed
I'm trying to add an object created from Entity Data Model classes. I have
I'm trying to use Dynamic Data with a entity model that has Abstract class
In console application I'm trying to get section key value pair but I couldn't.
I am trying to get the Enter key to trigger a function when it
I am trying to get the access key but I cannot make it work.
I am trying to get the user defined global hot key for my application.
I'm trying to do the same as Get the key corresponding to the minimum
I`m trying to figure out how to get serial and key attributes set for

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.