Ajax, Webmethod, PageMethod (multiple versions)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rory Becker

    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(Aja x.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


  • Michael Nemtsev [MVP]

    #2
    Re: Ajax, Webmethod, PageMethod (multiple versions)

    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


    Comment

    • Rory Becker

      #3
      Re: Ajax, Webmethod, PageMethod (multiple versions)

      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


      Comment

      • Michael Nemtsev [MVP]

        #4
        Re: Ajax, Webmethod, PageMethod (multiple versions)

        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


        Comment

        • Rory Becker

          #5
          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


          Comment

          • Steven Cheng [MSFT]

            #6
            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
            For those who may not know this, you can have an optional Parameter in SQL. It took me forever to figure it out.


            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

            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:
            msdnmg@microsof t.com.

            =============== =============== =============== =====
            Get notification to my posts through email? Please refer to
            Gain technical skills through documentation and training, earn certifications and connect with the community

            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: <3af103471a91a8 cabc95b183dc76@ news.microsoft. com>
            >From: Rory Becker <rorybecker@new sgroup.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
            >incorporatin g
            >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
            >
            >

            Comment

            • Steven Cheng [MSFT]

              #7
              Re: Ajax, Webmethod, PageMethod (multiple versions)

              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:
              msdnmg@microsof t.com.

              =============== =============== =============== =====
              Get notification to my posts through email? Please refer to
              Gain technical skills through documentation and training, earn certifications and connect with the community

              ications.
              =============== =============== ===============

              ----------------------------------------------------------------------------
              -----------
              >Content-Transfer-Encoding: 7bit
              >From: stcheng@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,
              >

              Comment

              • Rory Becker

                #8
                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 ICallbackEventH andler
                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


                Comment

                • Steven Cheng [MSFT]

                  #9
                  Re: Ajax, Webmethod, PageMethod (multiple versions)

                  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:
                  msdnmg@microsof t.com.

                  =============== =============== =============== =====
                  Get notification to my posts through email? Please refer to
                  Gain technical skills through documentation and training, earn certifications and connect with the community

                  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: <3af103471b3718 cac1eb248b4011@ news.microsoft. com>
                  >From: Rory Becker <rorybecker@new sgroup.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
                  ICallbackEventH andler
                  >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
                  >
                  >

                  Comment

                  Working...