Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Issue: The "Model" property will cause model is null [924]

$
0
0
I have Model Class "Project", it has a "Model" property, type is String.
When I create a Action as below:
[HttpPost]
public ActionResult Create(Project model)
{
if (ModelState.IsValid)
{
// save model into database
}
return View(model);
}
Run this action , I found the parameter "model" in Create method is always null, and with exception is "Can't convert String into Project".
Then , I change this property from "Model" to "ModelNumber", everything is OK!
Comments: Thanks for reporting this issue. This is an unfortunate side effect of model binding. Your workaround is right, but since the scenario is not very common we chose to keep it as is.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>