views:

46

answers:

2

After deploying a ASP.NET WebForms application to a production server some of the ajax calls has stopped working for me. After some debugging I found out that the following statement (in the internal client-method WebForm_DoCallback) was causing the problem:

xmlRequest.open("POST", action, true);

The problem seemed to be that the action-variable was empty so after checking the rendered html I found out that the form-tag rendered on the production server looks like:

<form method="post" action="" id="Form1">

However, on my developer machine I get the following:

<form method="post" action="default.aspx" id="Form1">

So, why would the action-attibute render on my dev.machine but not on the production server? This seems to be the case only for one specific web form, when I look on other pages the action-attribute renders correctly.

Any suggestions or ideas would be helpful!

A: 

I'm probably way off, but since you asked for any suggestions...

I don't know much about ASP, but in PHP, post variables are passed from the name attribute of the inputs, not the id attribute of the form itself. For instance:

<form id="test" method="post" action="test.php">
    <fieldset>
        <input name="firstname" type="text" />
        <input name="lastname" type="text" />
    </fieldset>
</form>

And on the server_side, if you did:

 print_r($_POST);

You would get:

 Array (
    [firstname] => Joe
    [lastname] => Smith
 )

Other than that, the only things that come to mind are:

  1. Make sure your form validates (the HTML itself),
  2. Check to see if your DTD is set to Strict or Transitional,
  3. Test to see if the issue is browser-side by testing on multiple variables,
  4. Throw in a type="hidden" input with a pre-set value, to see if that gets back to the server.

I doubt any of this is going to solve the problem, but I hope at the very least one of my suggestions uncovers some aspect that leads to a solution.

Anthony
A: 

ASP.NET in .NET 3.5 Service Pack 1 introduced some breaking changes regarding HTMLForm, so it may be worth checking that both servers have exactly the same framework version.

"Previous versions of ASP.NET always ignored the action attribute if it was present in the declarative markup for a element. Developers should remove the action attribute from their declarative markup to return to the original behavior where ASP.NET renders the postback Url."

Worth a shot.

Dan Diplo
it sounded like a good idea, but apparently the framework versions are exactly the same... I've solved the problem temporary by assigning the action-attribute in the client's onload-event, but i'll keep on looking at it..really strange behaviour...
Ozzy