2

On a page I have DropDownList and a LinkButton with the following code:

<asp:LinkButton ID="linkButton1" OnClick="FormSubmit" Text="CLICK ME" runat="server" />

Code behind:

protected void FormSubmit(object sender, EventArgs e)
{
    Response.Redirect("/location.aspx?dropDownValue=" + this.dropDownList.SelectedValue);
}

The purpose of which is for the user to select a value from the drop down list and be forwarded to a new page with a query string relating to that value.

On my local IIS this works find and redirects to localhost/location.aspx with the appropriate query string, however, on the remote server all that happens is that the page refreshes.

We've recently had a server outage and some settings on the server (e.g. firewall) have changed which may have thrown this out, but I cannot confirm for definite whether this is a problem that existed before.

So the question is: what would cause this difference in behaviour between my local IIS and the remote IIS?


Some more details:

Both are IIS 7 running .NETv2

I have tried https://stackoverflow.com/a/13498195/1185053 and https://stackoverflow.com/a/1953651/1185053

Community
  • 1
  • 1
dav_i
  • 27,509
  • 17
  • 104
  • 136
  • just guess, have you tried without slash - i mean "location.aspx..." ? – el vis Mar 19 '13 at 11:09
  • On the remote server, is `location.aspx` in the root of the website? Also, what are the actual requests/responses happening? Use something like Firebug to see what they are (what's being posted, if there's a redirect response, etc.). It also might be a good idea to put some sort of logging statement in `FormSubmit` to make sure it's being called at all. – David Mar 19 '13 at 11:10
  • Have you had a look in your browser-of-choice development tools to see which assets are requested? In Chrome Tools, you can check the Network tab to see the requests that are made when you click the link – levelnis Mar 19 '13 at 11:11
  • @pawlakppp, David: The path is pointing to the correct location - even if it weren't - I'd just get a 404, not the page refreshing. – dav_i Mar 19 '13 at 11:16
  • @levelnis I'll have a look and report back. – dav_i Mar 19 '13 at 11:16
  • @levelnis Doing the above confirms that it is just refreshing the page. – dav_i Mar 19 '13 at 11:42

1 Answers1

0

Check the ViewState. I observed the same thing recently. I had code with a link in a GridView which was working, but after merging with master pages I couldn't execute LinkButton server code. It had lost binding.

There is another case. My Visual Studio behaves weirdly sometimes. After I double click in design view it creates another event as linkbutton1_click in code behind.

So after activating `ViewState' / double clicking the linkbutton once I was able to bind the code behind event properly.

Hope it helps.

levelnis
  • 7,665
  • 6
  • 37
  • 61
Pavan N
  • 255
  • 2
  • 6
  • 21