简体   繁体   English

为什么HTML表单发布不能在WP7设备上正常工作?

[英]Why doesn't an HTML form post work properly on a WP7 device?

I'm currently developing a mobile site and I am having trouble getting it to work on WP7. 我目前正在开发一个移动网站,但无法在WP7上正常工作。 It's as basic as it doesn't pass data when doing a form submit. 它是基本的,因为在提交表单时不传递数据。 When I perform the submit, it will take me to the URL in the action but when I try and access data posted from that page it's null. 当我执行提交时,它将带我到操作中的URL,但是当我尝试访问从该页面发布的数据时,它为null。

I created a basic test page to see if something else on the site was interfering - but that wasn't the case, the following code is that of the test page. 我创建了一个基本的测试页,以查看网站上是否有其他干扰–并非如此,下面的代码就是该测试页的代码。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>

</head>
<body>
<form method="post" name="frmConfig" target="_blank" action="http://localhost/SessionTestApp/Default.aspx" >
    <input type="submit" value="Send" /><br />
    <textarea name="testpost" id="testpost" cols="80" rows="30" onclick="this.select()">
    </textarea>
</form>

</body>
</html>

and in the code behind of the aspx page I have the following C# 在aspx页面后面的代码中,我有以下C#

string strTest = "none";
strTest = Request["testpost"].ToString(); 
Response.Write(strTest);

I have tried it with a text area as above and an input box of type text. 我已经尝试了上面的文本区域和类型为text的输入框。 I have tried changing the submit to a button and using javascript to do the post. 我尝试将提交更改为按钮,然后使用javascript进行发布。

Bare in mind this code works on the emulators of 谨记此代码可在以下仿真器上运行

Android 2.1/2.2/2.3 Android 2.1 / 2.2 / 2.3
Blackberry v6 黑莓v6

and on the real devices of 并在

Android 2.1/2.2 Android 2.1 / 2.2
Blackberry v5 黑莓v5
Windows Mobile 6.5 - both IE and Opera Windows Mobile 6.5-IE和Opera

It also works in all desktop browsers - I can't find any reason for it but it doesn't work in the WP7 emulator or on a WP7 device. 它也可以在所有桌面浏览器中使用-我找不到任何原因,但是在WP7仿真器或WP7设备上不起作用。 If I have missed something or anyone could tell me why it would be greatly appreciated! 如果我错过了什么,或者任何人都可以告诉我为什么会非常感谢!

Tom 汤姆

If I connect to the page on the server (host PC of emulator image) then this works for me. 如果我连接到服务器(仿真器映像的主机PC)上的页面,则对我有用。
If I have the HTML on the phone (loaded via NavigateToString ) then this doesn't work. 如果我的手机上有HTML(通过NavigateToString加载),则此方法不起作用。 :( :(

How are you loading the content on the phone? 您如何在手机上加载内容?

It's fixed itself. 它是固定的。
I installed WAMP and posts worked. 我安装了WAMP,并且帖子正常工作。 I thought great... time to inspect IIS settings - at this point it still wasn't working using IIS. 我认为这很棒……是时候检查IIS设置了–此时,使用IIS仍然无法正常工作。
I did a bit more testing, I deleted all my testing html files from IIS's wwwroot and copied them back from apache's www. 我做了一些测试,我从IIS的wwwroot中删除了所有测试html文件,然后从apache的www中复制了它们。 Tried it again and it worked. 再次尝试,它奏效了。 Nothing more than deleting a file and recreating it. 只不过是删除文件并重新创建它。 If anyone has any insight as to why deleting and remaking a file stopped a POST changing to a GET in a request header please enlighten me... I've gone spare over the past couple of days. 如果有人对为什么删除和重新制作文件后停止在请求标头中将POST更改为GET有所了解,请赐教我...在过去的几天里,我已经不花时间了。
Also why did it only affect WP7? 还有为什么它只影响WP7? I suppose a situation like this it's similar to asking "What is the meaning of life?" 我想这样的情况类似于询问“生命的意义是什么?”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM