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

  • Home
  • SEARCH
  • 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 5846845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:38:04+00:00 2026-05-22T12:38:04+00:00

Ok I am near wits end here. I’ve got a simple MVC3 application with

  • 0

Ok I am near wits end here. I’ve got a simple MVC3 application with a viewmodel

ViewModel

    public class TicketViewModel {
    public Ticket Ticket { get; set; }

    [DisplayName("Name")]
    [Required(ErrorMessage = "Requestor's name is required.")]
    public string Name { get; set; } }

Controller

    [HttpPost]
    public ActionResult Create(TicketViewModel vm)
    {
        if(ModelState.IsValid) {

            TempData["message"] = "Your ticket has been submitted.";
            TempData["message-class"] = "success";

            return RedirectToAction("Index");
        }

        TempData["message-class"] = "error";

        return View("Index", vm);
    }

For some reason ModelState.IsValid is coming through as true all the time. Even when Name is left blank. It’s like the model/viewmodel isn’t validating at all. This works on other applications so I’m pretty sure I’m not hooking up something. I’ve got all the validation javascript included as well though I don’t think that’s the problem right now.

Update
Interestingly enough, the html tags that are being generated by @Html.TextBoxFor() are NOT including the data-val and data-val-required attributes.

View

@model MyApp.ViewModels.TicketViewModel

@{
    ViewBag.Title = "Tickets";
}

<div id="main-content">
    <section class="large">
      <div class="section">
        <div class="section-header">Submit Ticket</div>
        <div class="section-content">
          <div class="message"></div>

          @using( Html.BeginForm("Create", "Home", FormMethod.Post) ) {
            <h2>User Information</h2>
            <dl>
              <dt>@Html.LabelFor( m => m.Name)</dt>
              <dd>
                @Html.TextBoxFor( m => m.Name)
                @Html.ValidationMessageFor( m => m.Name)
              </dd>

              <dt></dt>
              <dd><button>Submit</button></dd>
            </dl>
          }
        </div>
      </div>
    </section>
</div>

UPDATE II

Well now this is interesting. I created a fresh app and got things working with basic code. Then when I added DI code to the global.asax.cs validations stopped working. Specifically, when I add

    public void SetupDependencyInjection() {
        _kernel = new StandardKernel();
        RegisterServices(_kernel);
        DependencyResolver.SetResolver(new NinjectDependencyResolver(_kernel));
    }

and call it from Application_Start()

    protected void Application_Start()
    {
        SetupDependencyInjection();

        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
    }

if I remove SetupDependencyInjection() validations start working. To be clear, DI works well but it seems to kill validations. This worked well prior to MVC3 Tools Update.

  • 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-22T12:38:05+00:00Added an answer on May 22, 2026 at 12:38 pm

    I was able to find a solution. Seems that when you install Ninject via nuget the configuration is a little different. It configures your application from the App_Start folder. Basically I was doubling up on my Ninject-Fu calling in from global.asax. This ended up causing the weird validation issues, though the other parts of the application were working.

    Ninject – Setting up an MVC3 application

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

Sidebar

Related Questions

In the near future i will get some 2 weeks for moving and improving
In the near future, I may be teaching a Ruby programming class to undergraduates
When objects from a CallList intersect the near plane I get a flicker..., what
In near future i'm going to develop a flash media server application when i'm
I have implemented MGTwitterEngine in my application and it works near to perfect. The
Table City Model class TableCity < ActiveRecord::Base has_many :near_cities, :foreign_key => nearcity_id end NearCity
My project is near completion, about to be rolled out into production. To get
iam developing iPhone application that allow user to define stations near to him, so
Can we make application that support NFC (near field communication) for android devices without
near the top of the code i see things like, btn_dropdown._visible = false; mcMenuBkg._visible

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.