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.
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");
WHGibbo
Member
19 Points
9 Posts
Problems with Server.Transfer
Oct 18, 2007 12:21 PM|LINK
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?
Luis Abreu
All-Star
25674 Points
5369 Posts
MVP
Re: Problems with Server.Transfer
Oct 18, 2007 08:54 PM|LINK
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
gt1329a
All-Star
15377 Points
2501 Posts
ASPInsiders
MVP
Re: Problems with Server.Transfer
Oct 18, 2007 10:23 PM|LINK
It seems like at that point, it would be simpler to just use a regular web service call.
A guide to combining jQuery and ASP.NET: jQuery for the ASP.NET developer
Luis Abreu
All-Star
25674 Points
5369 Posts
MVP
Re: Problems with Server.Transfer
Oct 19, 2007 07:36 AM|LINK
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