Render view as string then redirect.
- by JohnRudolfLewis
In my ASP.NET MVC application, I would like my controller action to render a view to a string, send an email using that string as the body, then do a redirect.
I've found several articles here on SO and elsewhere on how to render the view to a string. That part was easy.
But when I attempt to perform the redirect, I get an HttpException: Cannot redirect after HTTP headers have been sent. I've tried setting Response.Buffer and Response.BufferOutput to true, I've tried Response.Clear, nothing seems to work.
Is it possible to render a view to a string, then do a redirect?