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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:47:47+00:00 2026-05-23T03:47:47+00:00

What is wrong? Model is always null. Controller [HttpGet] public ViewResult Add() { return

  • 0

What is wrong? Model is always null.

Controller

[HttpGet]
public ViewResult Add()
{
    return View("Edit");
}

[HttpPost]
public ViewResult Add(Models.EditViewModel m)
{
    if (ModelState.IsValid)
    {
        return View("Success");
    }
    else
    {
        return View("Edit", m);
    }
}

Model:

public class EditViewModel
{
    [Required]
    [Display(Name = "JobTitle", ResourceType = typeof(DisplayNames))]
    public string Title { get; set; }

    [Required]
    [Display(Name = "JobDescription", ResourceType = typeof(DisplayNames))]
    public string Description { get; set; }
}

View

@model MyWebSite.Models.EditViewModel
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true, "Please correct the errors and try again.")
    @Html.EditorForModel()
    <input type="submit" value="Send" />
}

Rendered View

<script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<form action="/MyAction" method="post"><div class="editor-label"><label for="Title">Fun&#231;&#227;o</label></div>
    <div class="editor-field"><input class="text-box single-line" data-val="true" data-val-required="Informe um valor para Fun&amp;#231;&amp;#227;o" id="Title" name="Title" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="Title" data-valmsg-replace="true"></span></div>
    <div class="editor-label"><label for="Description">Descri&#231;&#227;o</label></div>
    <div class="editor-field"><input class="text-box single-line" data-val="true" data-val-required="Informe um valor para Descri&amp;#231;&amp;#227;o" id="Description" name="Description" type="text" value="" /> <span class="field-validation-valid" data-valmsg-for="Description" data-valmsg-replace="true"></span></div>
<input type="submit" value="Send" />
</form>
  • 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-23T03:47:48+00:00Added an answer on May 23, 2026 at 3:47 am

    Got it!
    The problem was a bad route that was creating a new model everytime.

    Changed

    routes.MapRoute(
        "Add", // Route name
        "AnnounceJob", // URL with parameters
        new { controller = "Jobs", action = "Add", job = new Models.EditViewModel() } // Parameter defaults
    );
    

    To

    routes.MapRoute(
        "Add", // Route name
        "AnnounceJob", // URL with parameters
        new { controller = "Jobs", action = "Add", job = UrlParameter.Optional } // Parameter defaults
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats wrong with my query? ALTER TABLE test_posts ADD sticky boolean NOT NULL default
I have a view model with a nullable int... public ObjectViewModel (){ public int?
Whats wrong with this picture? Model: validates_acceptance_of :terms_of_service, :on => :create, :accept => true,
For some reason the paramater OriginalLocation is always null in the following code. What
I have the following 2 models in my Google App Engine datastore: class Search(db.Model):
For some reason the paramater OriginalLocation is always null in the following code. What
Basically, I want to render a view and layout from a model. Don't ask
Consider the following model: public class BandProfileModel { public BandModel Band { get; set;
Don't get me wrong, I want them to get saved. But I always thought
Given the model Activity containing a bag with models of type Report (one to

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.