How do I reference a classic asp file from an MVC

2019-08-09 04:36发布

Apologies if this has already been answered elsewhere, I've been searching for an hour and haven't made any traction. I currently have a classic ASP website (not ASP.Net webforms). I wish to implement a new feature using MVC but have it display as part of the website in it's current form possibly using an iframe.

Currently I have a Visual Studio 2010 solution which contains the website and an MVC 4 internet project. My understanding is that I will probably have to use the MVC project as the startup one and then from the home controller index method redirect to the default.asp page that starts the asp website.

  1. Is there a better way to do this or am I on the correct track?

  2. Is this even possible to do?

1条回答
仙女界的扛把子
2楼-- · 2019-08-09 05:38

As I understand your question, what you want to do is to display the output of one of your .net mvc pages within a classic asp page. That should be possible with an Iframe, although there are more seamless ways. As explained in my comment on the other answer Classic ASP and ASP.net pages can exist in the same website, however none of the C# code will mean anything to the Classic pages. It might help to see your website as two separate projects living in the same root folder.

Rather than an Iframe I suggest you try a server http request. What this is doing in effect is taking the output of a .net mvc page as if it is an external webpage and pasting the contents into your Classic asp page. The code looks like this

<%
    Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
    objXML.Open "GET", "http://full-url-of-your-.net-mvc-page", false 
    objXML.Send("")
    Response.Write objXML.responseText
%>

IIS lets you specify any page you want as your website's landing page, you can do this through IIS manager

查看更多
登录 后发表回答