0

我是 ASP 领域的新手,想试用 ASP.NET Framework 4.0 MVC 4。在我们的域中,我有一个运行带有 MVC 的 IIS 7.5 的测试服务器和一个运行带有 .NET Framework 2.0 版本的 IIS 7.5 的生产服务器。我的问题:如何在不更改客户端浏览器中的 URL 的情况下将调用转移到生产服务器收到的 MVC 资源?修改生产服务器会导致我们的支持团队出现高血压,因此我的最后一个选择是使用 url 重写或对 IIS 进行任何其他修改的反向代理。我已经尝试过 server.transfer(url, true) 但它需要一个现有的 *.aspx 页面。欢迎解决。

4

1 回答 1

0

假设您的测试服务器上有 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
}
于 2012-07-27T11:35:42.827 回答