Tuesday, November 12, 2013

How to store resource into database or xml in ASP.NET MVC ?

http://afana.me/post/aspnet-mvc-internationalization-store-strings-in-database-or-xml.aspx

How to render a ASP.NET MVC view into html string?

        public string RenderRazorViewToString(string viewName, object model)
        {
            ViewData.Model = model;
            using (var sw = new StringWriter())
            {
                var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
                var viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
                viewResult.View.Render(viewContext, sw);
                viewResult.ViewEngine.ReleaseView(ControllerContext, viewResult.View);
                return sw.GetStringBuilder().ToString();
            }
        }
Reference:
http://stackoverflow.com/questions/483091/render-a-view-as-a-string