Behavior of HttpServerUtility::Transfer in v1.0 vs v1.1
A while back I had a customer complain that their web form application broke when they migrated from v1.0 to v1.1 of the .NET Framework. Turns out they utilized HttpServerUtility::Transfer (or more commonly in a Page class, Server.Transfer) and had some logic that relied on the presence or absence of form and query string variables. If we look at the definition for HttpServerUtility and then look at the Transfer method, we’ll see there are two overloads:
public void Transfer(string);
public void Transfer(string, bool);
Both of these methods will stop the execution of the current page and begin the execution of the new page that is passed in the string parameter (path). In the second overload, the boolean parameter (preserveForm) specifies whether to preserve the QueryString and Form collections. It is the documentation for this overload that is a bit misleading. For the preserveForm parameter it states:
preserveForm
If true, the QueryString and Form collections are preserved. If false, they are cleared. The default is false.
But the concept of a default doesn’t really apply in this case. If you don’t specify the parameter you are in fact calling the other overload. In v1.0, the end result was that if you called the first overload, the QueryString and Form collections were not preserved. In v1.1, they are. In fact in trying to reproduce and investigate this for my customer, I looked to the actual implementation in the Framework and in v1.0 the first overload basically calls the second, passing false for preserveForm. In v1.1 it passes true.
I’ve got a note into (hopefully) the right folks to get the documentation fixed, but in the meantime I’d do what I ultimately recommended to the developer that brought this to my attention – be explicit and pass true or false.
- Anonymous
May 06, 2004
FIX: Server.Transfer Does Not Invoke IsPostBack in .NET Framework 1.1
http://support.microsoft.com/default.aspx?scid=kb;en-us;821758
There are a couple more:
http://search.microsoft.com/search/results.aspx?qu=server.transfer&View=msdn&st=b&c=3&s=1&swc=3 - Anonymous
May 06, 2004
That was what I got as the explaination for why things act they way they do. As evidenced by the KB article, there are other things that may break between v1.0 and v1.1. The ultimate moral of the story is make sure you are current with hotfixes. - Anonymous
May 07, 2004
Hirlpoo:
http://support.microsoft.com/default.aspx?scid=kb;en-us;821758 mentions a HotFix so I guess it's not only a doc bug but a bug in asp.net v1.1, isn't it ? - Anonymous
May 11, 2004
My understanding is that hotfix "fixes" some of the plumbing that has the IsPostBack property busticated. - Anonymous
July 25, 2004
dianying xia zai:http://www.kamun.com/
movie down:http://movie.kamun.com/
mp3 xia zai:http://music.kamun.com/
engage:http://club.kamun.com/