locked
Unexpected behavior in ASP.NET VS2013 on handling Server.Transfer and Setting IsPostBack RRS feed

  • Question

  • In VS2013 (Update 4) using Framework 4.5 in VB, I experienced what I consider to be unexpected behavior regarding the IsPostBack and PreviousPage settings when using server.transfer's from button clicks to traverse from page to page. The transfers were all executed with the Preserve Form State (second parameter) set TRUE.

    After having problems in a production program, I tested this issue by creating a new VS2013 Web Site in Visual Basic using the ASP.NET Web Forms Site Template. I added three new web Forms as Test1.aspx, Test2.aspx and Test3.aspx, each using the auto-generated Site.Master. I used Server.Transfer's from a button click event in each page to access each next TestX page in a loop as:

    Test1 -> Test2 -> Test3 -> Test1

    The IsPostBack and PreviousPage settings worked as expected ONLY on the first transfer from Test1 -> Test2, but not for the next transfer of Test2->Test3. Instead, upon clicking the button in the Test2 page after its first showing, the Load event fires, but with the IsPostBack set to FALSE. Since it was posting back again from the first display of Test2, I expected IsPostBack to be TRUE.

    When I recreate my same test website of this condition FROM SCRATCH using VS2012 using its equivalent Web Forms Site Template and the exact code from the test pages in VS2013, the resulting VS2012 website transfers correctly from page to page on each and every first click, properly setting the IsPostBack and PreviousPage each time as expected.

    Furthermore, when I run the website created in VS2013 in VS2012, it exhibits the same unexpected and undesired behavior.

    Am I missing something here? Any help would be appreciated.
    • Moved by Jiayi Li Tuesday, September 29, 2015 6:44 AM
    Saturday, September 26, 2015 4:44 PM

Answers

  • Hi ArtH2,

    This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    As your issue is related to asp.net, I suggest you could consult this issue on this forum for dedicated support: http://forums.asp.net/18.aspx/1?Web+Forms

    Thank you for your understanding.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    • Marked as answer by ArtH2 Tuesday, September 29, 2015 12:03 PM
    Tuesday, September 29, 2015 6:31 AM

All replies

  • Hi ArtH2,

    This forum is discuss Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.

    As your issue is related to asp.net, I suggest you could consult this issue on this forum for dedicated support: http://forums.asp.net/18.aspx/1?Web+Forms

    Thank you for your understanding.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    • Marked as answer by ArtH2 Tuesday, September 29, 2015 12:03 PM
    Tuesday, September 29, 2015 6:31 AM
  • Probably your application is using RoutingConfig.cs to route between the pages.

    If you are using Server.Transfer instead then probably you need to make below changes

     public static void RegisterRoutes(RouteCollection routes)
            {
                #region Removed to fix Server.Transfer and IsPostback
                //var settings = new FriendlyUrlSettings();
                //settings.AutoRedirectMode = RedirectMode.Permanent;
                //routes.EnableFriendlyUrls(settings); 
                #endregion
                routes.EnableFriendlyUrls();
            }

    Tuesday, March 1, 2016 8:53 PM