2

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 using javascript to do the post.

Bare in mind this code works on the emulators of

Android 2.1/2.2/2.3
Blackberry v6

and on the real devices of

Android 2.1/2.2
Blackberry v5
Windows Mobile 6.5 - both IE and 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. If I have missed something or anyone could tell me why it would be greatly appreciated!

Tom

2
  • Should localhost really be in there? I've used plenty of TextArea POSTs within IE7 on WP7 and it seems to work OK.
    – Stuart
    Mar 29, 2011 at 8:32
  • I switched out the actual url for localhost just for this post :)
    – tom502
    Mar 29, 2011 at 8:38

2 Answers 2

0

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?

9
  • It's on a server - my local machine when using the emulator and an internal dev server when connecting with a device.
    – tom502
    Mar 29, 2011 at 9:25
  • @tom502 In which case I'm not sure. Is the code you posted what you're actually using? (people often post simplified versions) The code you posted works for me.
    – Matt Lacey
    Mar 29, 2011 at 9:51
  • It is a simplified version, but I have tested it with the code above and it still didn't work. What server are you using? I have a feeling it could be a setting somewhere... but that doesn't explain why it works on other platforms
    – tom502
    Mar 29, 2011 at 10:01
  • @tom502 No funny settings, I just kept everything default. Here's what I did cid-cc22250598bf7f04.office.live.com/self.aspx/Public/…
    – Matt Lacey
    Mar 29, 2011 at 10:24
  • @Matt Interesting. I'm completely lost on this - do you have any other suggestions?
    – tom502
    Mar 29, 2011 at 13:16
0

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?"

2
  • what version of IIS were you using? We get occassional (every few months) "strange behaviour" from IIS6 that we can't explain or understand and goes away after an IIS reset.
    – Matt Lacey
    Apr 1, 2011 at 13:59
  • I was getting the problem on 2 different servers - my machine and a dev/test server. My machine uses IIS 7.5 and the other uses IIS 6. As I said I deleted the files on my local machine and it worked after that - I didn't do anything to the other server but it works there now...
    – tom502
    Apr 1, 2011 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.