简体   繁体   English

如何在asp.net核心项目的MVC视图中读取Request.Form值?

[英]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.

相关问题 在 ASP.NET MVC 5 中使用 Request.Form - Using Request.Form in ASP.NET MVC 5 ASP.NET MVC-潜在危险的请求。表单值“ &lt;”和/或“&gt;” - ASP.NET MVC - Potentially dangerous request.Form value '<' and/or '>' C#ASP.NET MVC手动访问Request.Form和潜在危险值 - C# ASP.NET MVC Manually Accessing Request.Form & Potentially Dangerous values 如何在ASP.NET MVC 3中向用户显示“潜在危险的Request.Form值”错误消息 - How to display error message for “a potentially dangerous Request.Form value” to User in ASP.NET MVC 3 如何在 asp.net mvc 中的 juery 数据表的服务器端分页中转义 request.form 值? - How to escape request.form value in server side pagination of juery datatble in asp.net mvc? asp.net request.form - asp.net request.form ASP.NET MVC 控制器以字符串格式获取 Request.Form 如何从我的类对象中获取值? - ASP.NET MVC controller get Request.Form in string format how to get value from there in my class object? 如何从带有Request.Form的ASP.NET MVC中的选择(多个)中获取所有选择的选项? - How can i get all selected options from a select (multiple) in as ASP.NET MVC with Request.Form? asp.net mvc3 / 4 request.form从选择列表返回选择的值和选择的文本 - asp.net mvc3/4 request.form to return the selected value and the selected text from selectlist 尽管对ASP.NET MVC 2进行了修复,但仍然出现错误“从客户端检测到潜在危险的Request.Form值”? - Error “A potentially dangerous Request.Form value was detected from the client” despite the fixes for ASP.NET MVC 2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM