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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:49:38+00:00 2026-05-26T07:49:38+00:00

I have a view model public class DeviceModelEntryViewModel { public int ID { get;

  • 0

I have a view model

public class DeviceModelEntryViewModel
{
    public int ID { get; set; }

    [Required]
    [MaxLength(255)]
    public String Model { get; set; }

    [MaxLength(255)]
    public String Description { get; set; }

    [Required]
    [Display(Name = "Manufacturer")]
    public int ManufacturerID { get; set; }

    public SelectList ManufacturerList { get; set; }
}

In the DeviceModelController my Create method goes something like this:

[HttpPost]
public ActionResult Create(DeviceModelEntryViewModel model)
{
    if (ModelState.IsValid)
    {
        ...
        return RedirectToAction("Edit", new { id });  
    }

    return View(model);
}

The Create View is as follows:

@model ICMDB.ViewModels.DeviceModelEntryViewModel

@{ ViewBag.Title = "ICMD - Create Device Model"; }

<h2>Create Device Model</h2>

<div class="form-div">
    @using (Html.BeginForm()) {
        @Html.ValidationSummary(true)

        <fieldset>
            <div class="editor-label">
                @Html.LabelFor(model => model.Model)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Model)
                @Html.ValidationMessageFor(model => model.Model)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Description)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Description)
                @Html.ValidationMessageFor(model => model.Description)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.ManufacturerID)
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(model => model.ManufacturerID, 
                                      Model.ManufacturerList, "--None--")
                @Html.ValidationMessageFor(model => model.ManufacturerID)
            </div>
        </fieldset>

        <input type="submit" value="Save" class="form-button"/>
    }

    @using (Html.BeginForm("Index", "DeviceModel"))
    { <input type="submit" value="Cancel" class="form-button"/> }       
</div>

For some reason, whenever this function (or the Edit function which has a similar declaration) is hit, model is null. I checked, and it doesn’t even hit the zero arg constructor for DeviceModelEntryViewModel. I have done this for all my other controllers with their appropriate view models and they all work fine. I can’t seem to see what the difference is with this one that stops it from working.

Any ideas?

  • 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-26T07:49:39+00:00Added an answer on May 26, 2026 at 7:49 am

    Try changing the name of your Model property to something like:

    public String ModelName { get; set; }

    Don’t forget to update your view as well. I believe that should get it working correctly as the word Model seems to act like a reserved word and confuses the model binder.

    Edit: Here is a list of reserved words in Razor / MVC: Razor reseverd words

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

Sidebar

Related Questions

I have a view model - public class MyViewModel { public int id{get;set;}; Public
I have a view model public class ViewModel { public string Text { get;
In the world of MVC I have this view model... public class MyViewModel{ [Required]
I have the following model: public class Person { public string Name { get;
I have a view which displays a model eg: public class MyModel() { public
I have an IIdentifiable interface: public interface IIdentifiable { int Id { get; set;
I have the following view model: public class MyViewModel { public bool SingleFamily {
We have a screen and its view model: public class ScreenViewModel : BaseViewModel {
I have a fairly simple model: public class Delivery { public int DeliveryId {
I have a domain model: public class Project { [Key] public int ProjectID {

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.