首页 > 解决方案 > 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"];   
}

标签: asp.net-mvcasp.net-coreasp.net-core-mvc

解决方案


尝试这个:

string test = Context.Request.Form["testdata"];

您需要在请求前加上上下文。


推荐阅读