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

What did I do wrong? Here is an excerpt from my code: public void
For some reason the paramater OriginalLocation is always null in the following code. What
For some reason the paramater OriginalLocation is always null in the following code. What
Forgive me for probably using the wrong term for this application mode. Our application
Whats wrong with the following c# code? Compiler reports this error: Inconsistent accessibility: parameter
Why is it wrong to use std::auto_ptr<> with standard containers?
If something goes wrong in a WCF REST call, such as the requested resource
What's wrong with Linq to SQL? Or - what about Linq to SQL would
I wrote the wrong thing in a commit message. How can I change the
Am I doing something wrong or is it not possible to specify a generic

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.