locked
Get a return value from another webpage (using asp.net) server side RRS feed

  • Question

  • User-250171173 posted

    Hello,

    Can I use asp.net to get a return value from another webpage (relative url) from the same website. It would work exactly like jquery ajax call (just without using jquery / javascript).

    I need this done server side.

    The scenario is that I am generating pdf reports using itextsharp, I would like to include graphs generated dynamically on another webpage by first calling the page and then passing back the base64 representation of the image through a return value.

    Hopefully the explanation is clear enough to understand, I don't want the called webpage displayed to the user and don't want to save the image to the file system first, hence this approach.

    Any ideas / code examples would be appreciated.

    Sunday, November 9, 2014 5:00 PM

Answers

  • User-821857111 posted

    If all you are after is the graph that's generated on the other page, you should move the generation of the graph to a separate method that both pages can call. If you want the output from a Chart.Write call, you should put the code that creates and outputs the chart in a Helper.

    http://www.mikesdotnetting.com/article/173/the-difference-between-helpers-and-functions-in-webmatrix

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 9, 2014 5:23 PM
  • User-821857111 posted

    You should still separate the generation of the chart from the page. You can move your js into a separate file and call it from both pages. The alternative is to request the other page (using HttpClient) and then parse the source code.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 10, 2014 2:28 AM

All replies

  • User-821857111 posted

    If all you are after is the graph that's generated on the other page, you should move the generation of the graph to a separate method that both pages can call. If you want the output from a Chart.Write call, you should put the code that creates and outputs the chart in a Helper.

    http://www.mikesdotnetting.com/article/173/the-difference-between-helpers-and-functions-in-webmatrix

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 9, 2014 5:23 PM
  • User-250171173 posted

    Hello Mike, thanks for the reply

    The plan would be to have the generation of the graph on a separate page, as the graph would be generated using javascript / HTML5 / Canvas then output to a js variable 

    var pngUrl = canvas.toDataURL()

    so it can be returned to my .cshtml page.

    I just have very little idea on how to make the initial call from my .cshtml page to the chart generation page (.cshtml) and then make sure the only thing returned is the 'pngUrl', or event if this is possible.

    (I wont be using the chart helper at all).

    Sunday, November 9, 2014 9:51 PM
  • User-821857111 posted

    You should still separate the generation of the chart from the page. You can move your js into a separate file and call it from both pages. The alternative is to request the other page (using HttpClient) and then parse the source code.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 10, 2014 2:28 AM