Obvious compatibility bug in .Net 2.0 Beta 1 – your v1.1 code won’t work – level 100

This post is to share a backwards compatibility bug in v2.0 Beta 1.  I ran into this bug when porting a project of mine.  This wasn’t the only issue, but here it is.  Run this page under v1.1 and click the button to your heart’s content:

<%@ Page%>






<form id=”Form1″ method=”post” runat=”server”>

<asp:Button id=”Button1″ runat=”server” Text=”Button” OnClick=”Button1_Click”></asp:Button>




<script runat=”server”>

private void Button1_Click(object sender, System.EventArgs e)


Server.Transfer(Request.Path, true);



Now, run this page under v2.0.  You will click the button, and your computer will never return the page.  It will lock up.  But really it’s not.  Your computer is in an infinite loop.  This is because the second parameter of Server.Transfer has been changed. 

  • When set to true, in v1.1, the querystring would be preserved.
  • In v2.0, the form values are preserved as well.
  • Because the button element is a form element, the button submit is transfered also, so the page thinks that every run is a postback, so the page keeps Server.Transfer()ing back to itself until you kill it.

It’s nice that Microsoft added functionality, but we really just need another overload.  Leave the method like v1.1 because this broke my project, so I’m sure it will break some other projects.  Add an overload to accept a third parameter as a boolean which dictates whether to preserve the form values:

Server.Transfer(Request.Path, true, false);

I would use the above so that my querystring would be preserved but the form values would not.