Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Html from a Url in ASP.NET MVC

I need to save a page from url - This page is in my own application - in html format. This html will then be send by email to a user. Any anyone knows how?

like image 681
Jedi Master Spooky Avatar asked Feb 08 '09 13:02

Jedi Master Spooky


2 Answers

Well, you'll have to do it at the server to be able to e-mail - so at worst, simply:

using(WebClient client = new WebClient()) {
    string html = client.DownloadString(address);
}

It might also be possible to do it directly within MVC - perhaps RenderPartial?

like image 101
Marc Gravell Avatar answered Oct 08 '22 19:10

Marc Gravell


You could create a Result Filter or override the OnResultExecuted method of the controller to get access to the rendered page.

like image 21
Matthew Avatar answered Oct 08 '22 17:10

Matthew