Wie kann ich ein (binded) Modell von einer Ansicht an eine Controller-Methode zurückgeben, die kein [httppost] ist?Zurückgegebenes Modell von Ansicht an (nicht-httppost) Controller-Methode übergeben
Ausblick:
@Html.EditorFor(model => model.Name)
@Html.DisplayFor(model => model.Model)
// Table displays more properties of model
<input type="button" title="GetStuff" value="Get Stuff" onclick="location.href='@Url.Action("GetStuff")'" />
Controller-Methode:
public ActionResult GetStuff(ViewModel Model /* Realize this is non-httppost but...how can I get the model back with this type of scenario */)
{
// Get the name from per the model of the main view if the user changed it
string theName = Model.Name;
Model2 m2 = new Model2(){name = theName};
return ("someView", Model2);
}
Können Sie mir sagen, wie die Sig für den Controller aussehen würde? – JaJ
Genau wie das, was Sie in Ihrer Frage haben, sollte gut funktionieren. – Tommy