0

Possible Duplicate:
Render a view as a string

How can I render the results of a Controller Action to a string in MVC 3 (So I can send them as an email)?

Community
  • 1
  • 1
BowserKingKoopa
  • 2,701
  • 3
  • 33
  • 40
  • I don't think so. The answers there look like they're for MVC2 WebFormViews. I don't know how to make them work with MVC3 Razor Views. And I'm trying to render the result of a controller action, not necessarily render a view. – BowserKingKoopa Feb 25 '11 at 16:59
  • then maybe a [`WebClient`](http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx)? – Darin Dimitrov Feb 25 '11 at 17:03
  • If I used WebClient it wouldn't be in the context of the current user I don't think? The user is logged in but the WebClient wouldn't be. – BowserKingKoopa Feb 25 '11 at 17:11

1 Answers1

0

The most simple solution is probably this:

string body = Html.Action("Mail").ToHtmlString();
Lukáš Novotný
  • 9,012
  • 3
  • 38
  • 46