How can I save an action result to a file on disk in asp.net MVC?
public void Test()
{
var x = view();
//save x as a file on disk
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This method (add as a method to your controller type) will locate and fire a View and return a View Result as a string.
You can then take the string and do what you want with it.
I use it for email templating.
I then add these overloads a la the other mvc methods: