Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

            var htmlHelper = new HtmlHelper(new ViewContext(
                                     ControllerContext,
                                     new WebFormView(ControllerContext, "HACK"),
                                     new ViewDataDictionary(),
                                     new TempDataDictionary(),
                                     new StringWriter()),
                               new ViewPage());
            var otherViewHtml = htmlHelper.Action("About", "Home");

      HttpContext.Response.Clear();  
     HttpContext.Response.Charset = "";  
     HttpContext.Response.ContentType = "application/msword";  
     string strFileName = "test" + ".doc";  
     HttpContext.Response.AddHeader("Content-Disposition", "inline;filename=" + strFileName);  
     StringBuilder strHTMLContent = new StringBuilder();
     strHTMLContent.Append(otherViewHtml);       
     HttpContext.Response.Write(strHTMLContent);  
     HttpContext.Response.End();  
     HttpContext.Response.Flush();
            return View();
        }
Posted
Updated 18-Jun-15 18:29pm
v2

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900