2012-07-27 40 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 
} 
相關問題