asp.net-mvc - 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. 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"];
}
解决方案
尝试这个:
string test = Context.Request.Form["testdata"];
您需要在请求前加上上下文。
推荐阅读
- python - 如何检查子目录是否不包含python中的某个文件?
- svg - Visual Paradigm 生成的 svg 在 inkscape 中的呈现方式与在浏览器中不同
- java - 使用java加密解密,字符串到位,然后进行一些操作并返回到字符串
- javascript - 在 Angular 中通过 SCSS 格式化横向打印格式
- kotlin - 删除不确定是否存在的 Firestore 文档的最佳方法?
- angular - Angular 8 - 路由器导航到组件但不更改 URL
- c# - 如何在 .Net Core 3.0 中获得对 MS Access 的引用?
- powershell - 尝试在 PowerShell 中发出 curl POST 命令
- python - Django:为什么在虚拟环境中找不到包?
- c# - 使用 CAP 时如何设置 RabbitMQ 队列前缀