The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ViewExtensions.cs 1.3KB

1234567891011121314151617181920212223242526272829303132333435
  1. namespace Teknik.Utilities
  2. {
  3. public static class ViewExtensions
  4. {
  5. //public static string RenderToString(this PartialViewResult partialView)
  6. //{
  7. // var httpContext = HttpContext.Current;
  8. // if (httpContext == null)
  9. // {
  10. // throw new NotSupportedException("An HTTP context is required to render the partial view to a string");
  11. // }
  12. // var controllerName = httpContext.Request.RequestContext.RouteData.Values["controller"].ToString();
  13. // var controller = (ControllerBase)ControllerBuilder.Current.GetControllerFactory().CreateController(httpContext.Request.RequestContext, controllerName);
  14. // var controllerContext = new ControllerContext(httpContext.Request.RequestContext, controller);
  15. // var view = ViewEngines.Engines.FindPartialView(controllerContext, partialView.ViewName).View;
  16. // var sb = new StringBuilder();
  17. // using (var sw = new StringWriter(sb))
  18. // {
  19. // using (var tw = new HtmlTextWriter(sw))
  20. // {
  21. // view.Render(new ViewContext(controllerContext, view, partialView.ViewData, partialView.TempData, tw), tw);
  22. // }
  23. // }
  24. // return sb.ToString();
  25. //}
  26. }
  27. }