[英]How to read Request.Form values in MVC view of asp.net core project?
I have asp.net core MVC project and I can't use Request.Form in a view to read form data. 我有asp.net核心MVC项目,并且无法在视图中使用Request.Form来读取表单数据。 What is the alternative to read form data in asp.net core?
在asp.net核心中读取表单数据的替代方法是什么?
The name 'Request' does not exist in the current context. 名称“请求”在当前上下文中不存在。
@{
ViewData["Title"] = "Index";
string test = Request.Form["testdata"];
}
Try this: 尝试这个:
string test = Context.Request.Form["testdata"];
You need to prefix Request with Context. 您需要为“请求”加上上下文前缀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.