检索输入 type=password Request.Form[“strPassword”] 给出 null

发布于 2024-08-03 20:04:01 字数 1953 浏览 2 评论 0原文

尝试从元素为输入类型=“密码”的 HTML 表单读取数据时是否有任何特殊考虑?当 ColdFusion 页面使用表单数据发布我的处理程序时,我得到的密码为 null,而不是键入的值。

以下是下面较大块中的关键行:

string password = context.Request.Form["strPassword"];

我有一个 HTTPHandler.ashx 代码文件,它在发布时执行文件的上传。以下是此代码的关键片段:

        string username = context.Request.Form["strUsername"];
        if (String.IsNullOrEmpty(username))
        {
            IdentifyInvoker = GetUserInfo();
            brokerService = new Broker.FileService();
        }
        else
        {
            string password = context.Request.Form["strPassword"];
            string domain = context.Request.Form["strDomain"];
            IdentifyInvoker = GetInvokerInfoFromForm(username, password, domain);
            brokerService = new Broker.FileService(username,password,domain);
        }

发布上述代码的表单(来自 ColdFusion)如下所示:

<b>User Name</b> <input type="text" name="strUsername" id="strUsername" size="13" />   
<b>Password</b> <input type="Password" name="strPassword" id="strPassword" size="15" />   
<b>Domain</b> <input type="text" name="strDomain" id="strDomain" size="13" value="cbmiweb" />   

我能够使用调试器捕获此内容,并惊讶地发现此后: stringpassword = context.Request.Form["strPassword"];

...password = null

在立即窗口中,果然:

?context.Request.Form["strPassword"]
null

如果我在调试器中检查整个 Form 集合,我会看到正确的布局的值(用 & 分隔),并且没有一个重要的数据元素为 null (但奇怪的是,数据在等号前面包含一个加号)! 这是来自即时窗口的片段:

&strUsername=johna&strPassword+=xxxxxxxx&strDomain+=cbmiweb}

我有一个 ASP.NET 客户端,它可以 POST 到同一个 HTTPHandler,并且工作正常。这里显示的相同表单数据没有干扰加号:

&strUsername=johna&strPassword=xxxxxxxx&strDomain=cbmiweb}

关于导致此问题的原因以及如何在使用干扰加号进行格式化时检索表单数据有什么想法吗?

编辑: ASP.NET 表单和 ColdFusion 表单均指定 enctype="multipart/form-data",但后者嵌入了这些 PLUS 符号。

Are there any special considerations trying to read up data from an HTML form where the element is an input type="Password"? When a ColdFusion page POSTs my handler with form data I am getting null for the password instead of the typed value.

Here is the key line from the larger block below:

string password = context.Request.Form["strPassword"];

I have an HTTPHandler.ashx code file that performs an upload of a file when posted. Here is the key snippet of this code:

        string username = context.Request.Form["strUsername"];
        if (String.IsNullOrEmpty(username))
        {
            IdentifyInvoker = GetUserInfo();
            brokerService = new Broker.FileService();
        }
        else
        {
            string password = context.Request.Form["strPassword"];
            string domain = context.Request.Form["strDomain"];
            IdentifyInvoker = GetInvokerInfoFromForm(username, password, domain);
            brokerService = new Broker.FileService(username,password,domain);
        }

The form from which the above code is posted (from ColdFusion) looks like this:

<b>User Name</b> <input type="text" name="strUsername" id="strUsername" size="13" />   
<b>Password</b> <input type="Password" name="strPassword" id="strPassword" size="15" />   
<b>Domain</b> <input type="text" name="strDomain" id="strDomain" size="13" value="cbmiweb" />   

I was able to trap this with the debugger and was shocked to see that after this:
string password = context.Request.Form["strPassword"];

... password = null

In the immediate window, sure enough:

?context.Request.Form["strPassword"]
null

If I examine the entire Form collection in the debugger, I see the proper values laid out (separated by &) and none of the important data elements is null (but strangely the data contains a plus sign in front of the equal sign)! Here is a snippet from the immed window:

&strUsername=johna&strPassword+=xxxxxxxx&strDomain+=cbmiweb}

I have an ASP.NET client that POSTs to this same HTTPHandler and that works fine. Here the same form data shows without the interfering PLUS signs:

&strUsername=johna&strPassword=xxxxxxxx&strDomain=cbmiweb}

Any ideas on what causes this and how to retrieve the form data when it's formatted with the intervening PLUS signs?

EDIT:
Both the ASP.NET form and the ColdFusion form specify enctype="multipart/form-data" yet the latter embeds these PLUS signs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

女皇必胜 2024-08-10 20:04:01

加号是问题所在,它不应该在那里,您的coldfusion是将请求转发到您的页面还是它正在使用其内部http请求引擎来这样做?

由于空格而出现加号,请检查您的 Coldfusion 是否有任何字符串连接导致在您发布的数据中插入空格?

Plus sign is the problem, it should not have been there, is your coldfusion forwarding request to your page or it is using its internal http request engine to do so?

Plus sign appears due to white space, please check in your coldfusion if any string concatenation caused white spaces to be inserted in your posted data?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文