炫意html5
最早CSS3和HTML5移动技术网站之一

ASP.NET Core Razor Page如何在后台获得表单Post后的name-value值?

<p>后台用HttpContext.Request.Query[&quot;name1&quot;]获得的是空串。</p>
<hr>
<p>前端脚本是这样的:</p>
<p>function formPost(url,params){<br>
var form = document.createElement(&quot;form&quot;);</p>
<pre><code>form.action = url;
form.method = &quot;post&quot;;
form.target = &quot;_self&quot;;
form.style.display = &quot;none&quot;;
var item = {
name: ”,
value: ”
}
params = params !==undefined ? params : item;
//添加参数
for(var i in params){
var opt = document.createElement(&quot;input&quot;);
opt.name = params[i].name;
opt.value = params[i].value;
form.appendChild(opt);
</code></pre>
<p>}</p>
<p>document.body.appendChild(form);</p>
<p>form.submit();</p>
<p>return form;<br>
}</p>
<p>function start(){<br>
var a = [{<br>
name: &quot;data11&quot;,<br>
value: &quot;value1&quot;<br>
}];<br>
formPost(‘<a href=”https://localhost:44329/Index/In” target=”_blank”>https://localhost:44329/Index/In</a>’,a);<br>
}</p>

回答

HttpContext.Request.Form 是表单参数
HttpContext.Request.Query 是url 参数

炫意HTML5 » ASP.NET Core Razor Page如何在后台获得表单Post后的name-value值?

Java基础教程Android基础教程