3

I'm working on an ASP.net MVC 3 application. I have an external classic ASP file that renders a fragment of a page.

I understand that in ASP.net MVC 3, I can define a partial view to contain a fragment of HTML that I want to reuse on multiple pages.

The basic idea that I have is that I would like to use an external classic ASP file to render a fragment of HTML in my ASP.net MVC 3 application.

I would like to use it with something like Html.Partial, but that won't work because a classic ASP file is obviously not an MVC partial view.

Another way of doing this would be to add the content of the file to the page with AJAX, but I don't want to add the overhead of another AJAX call to my page. What might be the solution I'm looking for?

tereško
  • 58,060
  • 25
  • 98
  • 150
Vivian River
  • 31,198
  • 62
  • 198
  • 313
  • An iframe might work some some similar problems, but for the specific issue I have in mind, it is completely unsuitable. – Vivian River Apr 11 '12 at 15:44

2 Answers2

4

Plain HTML: Just read it from disk and output it with @Html.Raw().

Asp or other dynamically created content: You may use HttpWebRequest to get the html markup, and then insert into you own view. You may want to cache the response.

For convenience, you may create extension methods for both methods.

marapet
  • 54,856
  • 12
  • 170
  • 184
0

Create a Controller Action that makes the external call and returns the content:

Html.RenderAction("GetContent","ExternalASP"); //GetContent- Action, ExternalASP- Controller
rick schott
  • 21,012
  • 5
  • 52
  • 81
  • Aha, I think I see what the problem is now. When the client reaches the MVC 3 View, it will already have a session with the classic ASP site. However, it is impossible to do this server-side (in the MVC application) without writing more logic to identify the client to the classic ASP server. – Vivian River Apr 11 '12 at 15:41