简体   繁体   English

使用ASP.NET 3.5 ASPX页面从同一域中的服务器调用ASP.NET 4 MVC资源

[英]Call an ASP.NET 4 MVC resource from server on same domain using a ASP.NET 3.5 aspx page

i am a novice in the ASP land and would like to experiment with ASP.NET Framework version 4.0 MVC 4. Within our domain i have a test server running IIS 7.5 with MVC and a production server running IIS 7.5 with .NET Framework version 2.0. 我是ASP领域的新手,并且想尝试使用ASP.NET Framework 4.0 MVC4。在我们的域中,我有一个运行带有MVC的IIS 7.5的测试服务器和一个运行带有.NET Framework 2.0版的IIS 7.5的生产服务器。 My question: how do i transfer a call to a MVC resource received by the production server without changing the URL in the clients browser? 我的问题:如何在不更改客户端浏览器中的URL的情况下将呼叫转移到生产服务器接收的MVC资源? Modifying the production server wil cause high blood pressure within our support team so reverse proxy with url rewrite or any other modification to IIS is my last option. 修改生产服务器会导致我们的支持团队患上高血压,因此使用url重写或对IIS进行任何其他修改的反向代理是我的最后选择。 I have tried server.transfer(url, true) but it expects an existing *.aspx page. 我已经尝试过server.transfer(url,true),但是它期望现有的* .aspx页面。 Solutions welcome. 欢迎解决方案。

You might be able to do something like this, assuming you have a partial view served up by MVC on your test server: 假设您有MVC在测试服务器上提供的部分视图,您也许可以执行以下操作:

protected void Page_Load(object sender, EventArgs e)
{
    string content = null;
    var mvcTestSiteUrl = "whatever";
    WebRequest request = WebRequest.Create(mvcTestSiteUrl);
    WebResponse response = request.GetResponse();
    Stream stream = response.GetResponseStream();
    if (stream != null)
    {
        StreamReader reader = new StreamReader(stream);
        content = reader.ReadToEnd();
        reader.Close();
        stream.Close();
    }
    response.Close();
    // now you can try to put content into an asp:Label or asp:Literal, 
    // so you have the content of the MVC page to put in a production aspx.
    // this keeps your URL in production, and allows you to use the MVC content
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM