Search code examples
c#.netasp.net-mvcserver-side-includes

Server side include external HTML?


In my asp.net-mvc application I need to include a page that shows a legacy page. The body of this page is created by calling an existing Perl script. This Perl script is externally hosted.

Is there a way to do something like this:

<!-- #Include virtual="http://www.example.com/theScript.plx"-->

Solution

  • Not as a direct include, because ASP.NET server-side-includes require the page to be compiled at the server.

    You could use jQuery to download the HTML from that URL when the page loads, though I appreciate that's not perfect.

    Alternatively (and I have no idea whether this will work) you could perform a WebRequest to the perl webpage from your ASP.NET MVC controller, and put the resulting HTML in the view as text. That way you could make use of things like output caching to limit the hits to the perl page if it doesn't change often.