user1556917
user1556917

Reputation: 1

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. 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? 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. I have tried server.transfer(url, true) but it expects an existing *.aspx page. Solutions welcome.

Upvotes: 0

Views: 168

Answers (1)

danludwig
danludwig

Reputation: 47375

You might be able to do something like this, assuming you have a partial view served up by MVC on your test server:

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
}

Upvotes: 0

Related Questions