I have the following view
@model CaseConverterModel
<h1 >Title Case Converter</h1>
<h4 >Smart Title Capitalization Tool</h4>
<div >
<div >
</div>
<div >
<form asp-action="ConvertToTitleCase">
<textarea id="txtText" style="width:100%"></textarea>
<br />
<input type="submit" value="Convert" />
<hr />
<p>@Model.OutPutText</p>
</form>
</div>
<div >
</div>
</div>
Following Controller
public IActionResult Index()
{
return View();
}
[HttpPost]
public IActionResult ConvertToTitleCase(string inputText)
{
var obj = new CaseConverterModel();
obj.OutPutText = "this is test";
return View(nameof(Index), obj);
}
Here is the Model
public class CaseConverterModel
{
public string InputText { get; set; }
public string OutPutText { get; set; }
}
When I run it it shows following error message
How to solve this?
CodePudding user response:
@Yong Shun said is right.
Your <p>@Model.OutPutText</p>
need the model value, but in your (get) Index()
method , you don't pass the model.