2012-07-27 44 views
0

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

+0

所以,你想委托从生产服务器站点呼叫到测试站点并将测试服务器站点的响应返回给客户端? – 2012-07-27 08:04:03

回答

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 
} 
相关问题