Reputation: 2902
I have asp.net core MVC project and I can't use Request.Form in a view to read form data. What is the alternative to read form data in asp.net core?
The name 'Request' does not exist in the current context.
@{
ViewData["Title"] = "Index";
string test = Request.Form["testdata"];
}
Upvotes: 1
Views: 2983
Reputation: 14555
Try this:
string test = Context.Request.Form["testdata"];
You need to prefix Request with Context.
Upvotes: 4