471,075 Members | 709 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 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 2394
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Sandman | last post: by
2 posts views Thread by Zeba | last post: by
17 posts views Thread by Arjen | last post: by
2 posts views Thread by germ | last post: by
3 posts views Thread by =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post: by
3 posts views Thread by George | last post: by

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.