html - html 表单发布到 aspx 页面,标题字段未发布。Chrome 说请求是 GET,根本不显示表单数据
问题描述
下面是发帖页面:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Properties login</title>
</head>
<body>
<form id="formstart" method="POST" action="proplist.aspx">
<table id="loginTable" class="center">
<tr>
<td><label >User name</label></td>
<td><input type="text" name="usertext" text="asm"/></td>
</tr>
<tr>
<td><label ID="passwd" >Password</label></td>
<td><input type="text" name="passtext" text=""/></td>
</tr>
<tr>
<td><label ID="Label2" >Press to continue</label></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
简单的html,没有asp,以防万一导致任何问题。这是目标aspx页面:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="proplist.aspx.cs" Inherits="PropertyW.proplist" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="formlist" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Comic Sans MS" Font-Size="Larger" ForeColor="#3333CC" Text="Property List"></asp:Label>
<div id="loginResponse" runat="server" >not logged in
</div>
<div id="namePassed" runat="server"></div>
</form>
</body>
</html>
这是后面的代码。
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PropertyW
{
public partial class proplist : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
NameValueCollection nvc = Request.Form;
string userName = "asm", password = "17kgrovE";
string sName = Request.Form["usertext"];
string sPass = nvc["passtext"];
if (nvc.Count > 0)
{
sName = nvc["usertext"] + ".nvc";
}
string sMsg = string.Format("name passed = {0}, nvc count = {1}", sName, nvc.Count);
namePassed.InnerHtml = sMsg;
if (!string.IsNullOrEmpty(sName))
{
userName = sName;
}
if (!string.IsNullOrEmpty(sPass))
{
password = sPass;
}
// CheckLogin(userName, password);
}
}
}
}
这是 chrome 在网络选项卡中显示的内容。表单数据没有条目。在表单字段后面的代码中为空。(用户文本和密码)。即使代码是 POST,Chrome 也会将请求显示为 GET。
解决方案
推荐阅读
- angular - Angular/ChromeHeadless 单元测试在 Visual Studio Online 上失败
- php - 如何格式化 FullCalendar eventSources URL 的结果数据
- dongle - 如何更改 Thread COAP 示例以使用 NRF 52840 加密狗
- dialogflow-es - 隐式调用意图的帐户链接
- excel - Excel 中的按比例假期公式
- ios - 错误:从 xcode 9 升级到 xcode 10.1 后
- android - 列表视图android studio中的错误颜色映射
- css - Flex wrap 镀铬问题
- wordpress - 从数组中的当前循环中获取所有 post_id
- ibm-cloud - 不工作 SoftLayer_User_Customer::addBulkPortalPermission