I'm currently developing a mobile site and I am having trouble getting it to work on 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.
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#
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. I have tried changing the submit to a button and usin开发者_运维百科g javascript to do the post.
Bare in mind this code works on the emulators of
Android 2.1/2.2/2.3
Blackberry v6and on the real devices of
Android 2.1/2.2
Blackberry v5 Windows Mobile 6.5 - both IE and OperaIt 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. 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.
If I have the HTML on the phone (loaded via NavigateToString
) then this doesn't work. :(
How are you loading the content on the phone?
It's fixed itself.
I installed WAMP and posts worked. I thought great... time to inspect IIS settings - at this point it still wasn't working using 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. 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.
Also why did it only affect WP7? I suppose a situation like this it's similar to asking "What is the meaning of life?"
精彩评论