我如何从一个MVC项目中引用经典的asp文件 [英] How do I reference a classic asp file from an MVC project

查看:165
本文介绍了我如何从一个MVC项目中引用经典的asp文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

道歉,如果这已经回答了其他地方,我一直在寻找一个小时,并没有作出任何的牵引力。我现在有一个传统的ASP网站(不ASP.Net web表单)。我想使用MVC实现一个新的功能,但有它显示为网站的一部分,这是目前的形式可能使用iframe。

目前我有一个Visual Studio 2010的解决方案,其中包含了网站和一​​个MVC 4互联网项目。我的理解是,我将可能不得不使用MVC项目作为启动一个,然后从主控制器指数方法重定向到启动的asp网站的default.asp页。


  1. 有没有更好的办法做到这一点还是我正确的轨道上吗?


  2. 这甚至可能做什么?



解决方案

据我了解你的问题,你想要做的是一个传统的ASP页面中显示你的.NET MVC网页之一的输出。这应该是可能的的iframe,虽然有更完美的方式。由于对对方的回答在我的评论解释了经典的ASP和ASP.net页面可以在同一个网站存在,但没有一个C#code将意味着什么经典的网页。这可能有助于看看你的网站,生活在同一个根文件夹两个独立的项目。

而不是iframe我建议你尝试的服务器的HTTP请求。这是什么实际上做的是一个.NET MVC页面的输出,就好像它是一个外部的网页和内容粘贴到您的经典ASP页。在code看起来像这样

 <%
    设置objXML =的Server.CreateObject(MSXML2.ServerXMLHTTP.6.0)
    objXML.OpenGET,HTTP://full-url-of-your-.net-mvc-page,假
    objXML.Send()
    回复于objXML.responseText
%GT;

IIS允许你指定你想为你的网站的目标网页的任何页面,则可以通过IIS管理器中做到这一点。

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?

解决方案

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

这篇关于我如何从一个MVC项目中引用经典的asp文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆