Last Updated: February 25, 2016
·
2.535K
· iondrimba

Render Web Page in C# + ASP.NET MVC

//HTML VIEW

<h2>Web Page</h2>
<div>
    @{
        Html.RenderAction("GetWebPage");
    }
</div>

//MVC CONTROLLER

public ActionResult GetWebPage()
{
    string result = string.Empty;
    try
    {
        using( WebClient client = new WebClient() )
        {
            result = client.DownloadString("http://coderwall.com");
        }
    }
    catch( Exception e)
    {
        result = e.Message;
    }

    return Content(result);
}