Visual studio 2015 请求。表格在VS 2015中不起作用
我不明白为什么以下代码在VS 2012中有效而在VS 2015中无效: getdata.html:Visual studio 2015 请求。表格在VS 2015中不起作用,visual-studio-2015,request.form,Visual Studio 2015,Request.form,我不明白为什么以下代码在VS 2012中有效而在VS 2015中无效: getdata.html: <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> </head> <body> <form id="getcase"
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<form id="getcase" name="getcase" action="submit2crm.aspx">
<input id="Text1" type="text" name="txt" />
<input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
submit2crm.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class w2c_submit2crm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Text.StringBuilder displayValues = new System.Text.StringBuilder();
System.Collections.Specialized.NameValueCollection postedValues = Request.Form;
String nextKey;
for (int i = 0; i < postedValues.AllKeys.Length; i++)
{
nextKey = postedValues.AllKeys[i];
if (nextKey.Substring(0, 2) != "__")
{
displayValues.Append("<br>");
displayValues.Append(nextKey);
displayValues.Append(" = ");
displayValues.Append(postedValues[i]);
}
}
Label1.Text = displayValues.ToString();
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.UI;
使用System.Web.UI.WebControl;
公共部分类w2c_submit2crm:System.Web.UI.Page
{
受保护的无效页面加载(对象发送方、事件参数e)
{
System.Text.StringBuilder displayValues=新的System.Text.StringBuilder();
System.Collections.Specialized.NameValueCollection postedValues=Request.Form;
字符串nextKey;
对于(int i=0;i”);
displayValues.Append(nextKey);
displayValues.Append(“=”);
Append(postedValues[i]);
}
}
Label1.Text=displayValues.ToString();
}
}
提交表单后,postedValues仍然为空。
有什么想法吗?我自己发现了问题:
这是一个友好的URL功能。要发出请求.Form working,我将配置文件RouteConfig.cs中的settings.AutoredirectMode更改为Off:
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Off;
routes.EnableFriendlyUrls(settings);
RouteConfig.cs位于App_开始文件夹中
这篇文章帮助我了解问题所在: