473,222 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,222 software developers and data experts.

Ajax, Webmethod, PageMethod (multiple versions)

Hi All

I have a need for an asp.net page to make a call to a server which it did
not originate from when a button is clicked.

A simple call to pass 2-3 params and return a result. I am happy to use an
asynchronous model to do this.

I control both servers. I have been looking at Ajax and PageMethods (Ajax.Net
and Ajax Pro) and have even been looking at Calling a webservice from JS.

I need the client code for this to be as simple as possible as I am going
to have to generate it dynamically on the server side.

I looked at using pagemethods(Ajax.Net) but I realised that the page that
has to generate the calling code is not the page which willl be recieving
the call.

Should I call back to site 1 using pagemethods and then call out on the server
side to the Site2?

What is the single simplest way I can do this?

Thanks in advance

--
Rory
Jul 25 '08 #1
8 2477
Hello Rory,

not quite understood the following

RBI realised that the page that has to generate the calling code is
RBnot the page which willl be recieving the call.

pagemethods allow you to call the server methods from client code.
You are using the same page to call the pagemethod and receive the result
back

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
Jul 25 '08 #2
Hello Michael Nemtsev [MVP],
not quite understood the following
RB>I realised that the page that has to generate the calling code is
RB>not the page which willl be recieving the call.
RB>>
pagemethods allow you to call the server methods from client code.
You are using the same page to call the pagemethod and receive the
result
back

I wish to have the user visit http://site1.com/Page1.aspx

Page1.aspx needs to then, at some point, make a call to a method whose implementation
is actually at http://site2.com/Page2.aspx

I thought that Pagemethods only allowed the button which was generated in
page1 to call back to a method on page1.

Am I wrong?

--
Rory
Jul 25 '08 #3
Hello Rory,

Ohhh. actually even if it were allowed to do this, I'd strongly don't recommed
you to do this, because it's gonna be mess.
You need to divide these domain areas. And I consider that incorporating
all specific loging into web Service will be the best case for you.

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
RBHello Michael Nemtsev [MVP],
RB>
>not quite understood the following
RB>>I realised that the page that has to generate the calling code is
RB>>not the page which willl be recieving the call.
RB>>>
>pagemethods allow you to call the server methods from client code.
You are using the same page to call the pagemethod and receive the
result
back
RBI wish to have the user visit http://site1.com/Page1.aspx
RB>
RBPage1.aspx needs to then, at some point, make a call to a method
RBwhose implementation is actually at http://site2.com/Page2.aspx
RB>
RBI thought that Pagemethods only allowed the button which was
RBgenerated in page1 to call back to a method on page1.
RB>
RBAm I wrong?
RB>
RB--
RBRory
Jul 25 '08 #4
Hello Michael Nemtsev [MVP],
Hello Rory,

Ohhh. actually even if it were allowed to do this, I'd strongly don't
recommed
you to do this, because it's gonna be mess.
You need to divide these domain areas. And I consider that
incorporating
all specific loging into web Service will be the best case for you.
Ok I'm stil a little confused.

are you suggesting

1.Pagemethod call from Page to Site1 which calls a webservice hosted on
Site2?

2.Page uses webservice hosted on Site 2 directly?

3.Something else I didn't think of ?

Thanks for your help in this

--
Rory
Jul 25 '08 #5
Hi Rory,

As for the webservice on another web application(you want to call in
originate page), is it under the same website or the same main domain
address? For client-side scirpt, we can make webrequests call to other
application, but it has limitation that we cannot perform cross domain
webrequests. If this is not a problem and what you want to do is just a
simple request with some parameters and a return value, I think you can
even use an httphandler on the remote application and let your original
application call that httphandler via xmlhttp post request:

#Use the XMLHttpRequest Object to Post Data
http://www.devx.com/DevX/Tip/17500

I also found the the following web article which mentioned some info about
calling remote AJAX webservice:

#JSON in ASP.NET Ajax: Part 2. Calling a remote JSON Web Service from
client script
http://geekswithblogs.net/JuanDoNebl...in_aspnetajax_
part2.aspx

In addition, for the worst case that the above approaches not work, you can
still consider make a call AJAX webservice call(to the same page's
pagemethod) and let it do a server-side remote call or directly access the
server-side resource. How do you think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>Date: Fri, 25 Jul 2008 16:47:51 +0000 (UTC)
Message-ID: <3a**************************@news.microsoft.com >
From: Rory Becker <ro********@newsgroup.nospam>
Subject: Re: Ajax, Webmethod, PageMethod (multiple versions)
>
Hello Michael Nemtsev [MVP],
>Hello Rory,

Ohhh. actually even if it were allowed to do this, I'd strongly don't
recommed
you to do this, because it's gonna be mess.
You need to divide these domain areas. And I consider that
incorporating
all specific loging into web Service will be the best case for you.

Ok I'm stil a little confused.

are you suggesting

1.Pagemethod call from Page to Site1 which calls a webservice hosted on
Site2?

2.Page uses webservice hosted on Site 2 directly?

3.Something else I didn't think of ?

Thanks for your help in this

--
Rory
>
Jul 28 '08 #6
Hi Rory,

Any progress on this issue or still need any help?

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
=============================================

----------------------------------------------------------------------------
-----------
>Content-Transfer-Encoding: 7bit
From: st*****@online.microsoft.com (Steven Cheng [MSFT])
Organization: Microsoft
Date: Mon, 28 Jul 2008 04:25:22 GMT
Subject: Re: Ajax, Webmethod, PageMethod (multiple versions)
>Hi Rory,

As for the webservice on another web application(you want to call in
originate page), is it under the same website or the same main domain
address? For client-side scirpt, we can make webrequests call to other
application, but it has limitation that we cannot perform cross domain
webrequests. If this is not a problem and what you want to do is just a
simple request with some parameters and a return value, I think you can
even use an httphandler on the remote application and let your original
application call that httphandler via xmlhttp post request:

#Use the XMLHttpRequest Object to Post Data
http://www.devx.com/DevX/Tip/17500

I also found the the following web article which mentioned some info about
calling remote AJAX webservice:

#JSON in ASP.NET Ajax: Part 2. Calling a remote JSON Web Service from
client script
http://geekswithblogs.net/JuanDoNebl..._in_aspnetajax
_
>part2.aspx

In addition, for the worst case that the above approaches not work, you
can
>still consider make a call AJAX webservice call(to the same page's
pagemethod) and let it do a server-side remote call or directly access the
server-side resource. How do you think?

Sincerely,
Aug 1 '08 #7
Hello Steven Cheng [MSFT],
Any progress on this issue or still need any help?
My appologies for not getting back to the list on my conclusions here.

I have gone with a solution in volving the implementation of ICallbackEventHandler
in a control which I place on the form on Site1

In the handler for this I then contact Site2 behind the scenes.

In this way I do not risk exposure of fairly critical security info which
I realised needs to be passed by the call.
I am finding that this solution works very well indeed and also allows me
to move the control to other pages with relative ease.

Thanks to all for help in this matter.

--
Rory
Aug 1 '08 #8
Thanks for your reply Rory,

I'm glad that you've already got it working and also thanks for sharing the
solution with us. That'll also benefit other ones dealing with the same
scenario.

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Date: Fri, 1 Aug 2008 11:42:07 +0000 (UTC)
Message-ID: <3a**************************@news.microsoft.com >
From: Rory Becker <ro********@newsgroup.nospam>
Subject: Re: Ajax, Webmethod, PageMethod (multiple versions)
>
Hello Steven Cheng [MSFT],
>Any progress on this issue or still need any help?

My appologies for not getting back to the list on my conclusions here.

I have gone with a solution in volving the implementation of
ICallbackEventHandler
>in a control which I place on the form on Site1

In the handler for this I then contact Site2 behind the scenes.

In this way I do not risk exposure of fairly critical security info which
I realised needs to be passed by the call.
I am finding that this solution works very well indeed and also allows me
to move the control to other pages with relative ease.

Thanks to all for help in this matter.

--
Rory
>
Aug 4 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: =?Utf-8?B?VHJlbnQ=?= | last post by:
I have tied an AutoCompleteExtender to a textbox to indicate suggestions to the user. Everything works fine if I utilize a webservice to fetch the results. However, I want to put the web service...
3
by: Sandman | last post by:
So, I've used ajax for quite some time for different stuff. Mostly I just feed a funktion I made with the ID of the DIV that should be updated with the output from page XXX.php Now I want to...
2
by: Zeba | last post by:
Hi guys! I'm new to JS / Ajax; I've been trying to do an Ajax call to my Webservice ( I'm using C# for code-behind). I'm not using any of the libraries available. I am sending my CustID to the...
17
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);"...
2
by: germ | last post by:
doing a simple page webmethod call an a page via PageMethods works fine in ie7 & opera9 the same call on firefox ( and I assume netscape ) generates the following error : Error: " nsresult:...
3
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
In an earlier thread (http://tinyurl.com/33horg) I learned that when session is enabled on a web page, a second page method is blocked until the first one is complete. Is there any way around...
2
by: brice | last post by:
Hi, We are using static public methods decorated with 'WebMethod' as our AJAX implementation. We then use the client-side Sys.Net.PageMethod approach to invoke the page method. In the same...
1
by: daokfella | last post by:
I have a Webmethod in a server control which needs to be called using AJAX. The control writes a javascript block that uses setTimeout to call a an ajax js function after 10 seconds. When...
3
by: George | last post by:
I am doing an AJAX call using JQuery on my page to which returns JSON objects and everything works fine. Now I decided to use ashx handler instead of and simply write JSON out. Then my problems...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.