Problems with Server.Transfer

Last post 10-19-2007 3:36 AM by Luis Abreu. 3 replies.

Sort Posts:

  • Problems with Server.Transfer

    10-18-2007, 8:21 AM
    • Member
      19 point Member
    • WHGibbo
    • Member since 04-20-2005, 1:37 PM
    • Posts 9

    Hi,
    Was wondering if anybody could help??

    I have a page called countrytest.aspx, which basically attempts to work the users country and then redirects them to the current page using Server.Transfer(.....).  The reason for doing this is to stop the url from being updated.
    The page that it is being sent (DefaultUSA.ASPX) to has a ScriptManager on it and a pagemethod, the pagemethod is invoked by some javascript on the page load.

    The page DefaultUSA.ASPX works find, when it is entered in the address bar :D

    But when it is transferred from another page, it isn't causing the javascript to crash as the pagemethod doesn't exist.

     Any ideas?

     

     

    Gibbo
  • Re: Problems with Server.Transfer

    10-18-2007, 4:54 PM
    Answer
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    Hello.

    yes, you've diagnosticated everything correctly :)

     

    now, the only thing you need to know is that calling a page method is really similar to calling a web service method. what this means is that you should be able to do what you want. Here's what you need to do:

    1. handle the invokingRequest of the webrequestmanager

     2.  check to see if the urls is correct; if it's not, then correct it

    all this in javascript. for instance, suppose you're calling a method SayHello which is available on the page default11.aspx. here's the js code that will redirect the code for the current page:

    function intercept( sender, e ){
        var url = e.get_webRequest().set_url("/julyaspnet/Default11.aspx/SayHello");
       
    }

    Sys.Net.WebRequestManager.add_invokingRequest( intercept );

     

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: Problems with Server.Transfer

    10-18-2007, 6:23 PM
    • Star
      13,849 point Star
    • gt1329a
    • Member since 06-24-2002, 12:53 AM
    • Atlanta
    • Posts 2,290
    • TrustedFriends-MVPs

    It seems like at that point, it would be simpler to just use a regular web service call.

    Encosia - ASP.NET, jQuery, AJAX, and more.

    Latest article: How you can force the Ajax Script Loader to use jQuery 1.4
  • Re: Problems with Server.Transfer

    10-19-2007, 3:36 AM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 1:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    • TrustedFriends-MVPs

    hello.

    maybe. but if you've already have a page with several methods, i think that adapting it in this scenario is really easier than build web services...

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
Page 1 of 1 (4 items)