1

I have a very strange issue. My appplicaiton works fine on my PC (as usual), but when I deploy it to production, it does the following:

  • When I access site by typing http://localpet.cloudapp.net/ then when I select item from dropdown list which is meant to load another dropdown list, value gets cleared from the first dropdown, as if it is not posting back but rather redirects to the same page or refreshes it
  • When I access site using http://localpet.cloudapp.net/Default.aspx then everything works fine, all postback function as expected

You can try it for yourself, got to my url and try to pick Animal Type from dropdown box. Value gets cleared. But if you specify page "Default.aspx" it works fine. I am not doing any explicit page redirects. On my local PC I tried with both Casini and IIS and it works fine. Please help

fenix2222
  • 4,602
  • 4
  • 33
  • 56

1 Answers1

3

Have a look at changes in ASP.NET 4.0.

Event Handlers Might Not Be Not Raised in a Default Document in IIS 7 or IIS 7.5 Integrated Mode.

ASP.NET 4 now renders the HTML form element’s action attribute value as an empty string when a request is made to an extensionless URL that has a default document mapped to it. For example, in earlier releases of ASP.NET, a request to http://contoso.com would result in a request to Default.aspx. In that document, the opening form tag would be rendered as in the following example:

<form action="Default.aspx" />

In ASP.NET 4, a request to http://contoso.com also results in a request to Default.aspx. However, ASP.NET now renders the HTML opening form tag as in the following example:

 <form action="" />

Some work around mentioned in posted link (article) and SO thread - Postback doesn't work with aspx page as Default Document.

Here is another way to set action attribute. You have to write following code in Page_Load handler of Default.aspx.

 HtmlForm form=Master.FindControl("form1") as HtmlForm;
 form.Action = "Default.aspx";
Community
  • 1
  • 1
KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
  • So what do I do? My form tag is in master page, so by adding
    to masterpage wouldn't this tell it to always look at default.aspx page?
    – fenix2222 Jun 08 '12 at 02:54