How to view the controller's resulting html in debug with ASP.NET MVC? -


While debugging the result of an administrator's action (html, xml, json), I can see

< P> For example, in my controller this is:

  reload public partial view () {partial view ("index"); }  

While debugging, I want to see what HTML will be sent to the client. Thanks

This is not easy, because partial view results are sent directly to httpcontext.current.response.output It does not return the string, you can filter it by using the extension method, by filtering it as a HK kontex output:

  /// & lt; Summary & gt; Presents a view for the string. & Lt; / Summary & gt; Public Stabilized String RenderViewToString (This Controller Controller, String Visionname, Object ViewData) {// Existing response is getting response var = Feedback HttpContext.Current.Response; // response flushing Flush (); // View footage view view = scene engine. Engine. View of FundPartel (Controller Controller Contex, Visualization). See; // Create visual footage vs. visual view = new viewfinder (controller Controller Contax, View, Controller Viewdata, Controller.Tempadata); // Since RenderView goes straight to HttpContext. Currently, we have to filter out our footage and filter out the old filter. Stream filter = new memorystream (); ; Try {response.Filter = filter; ViewContext.View.Render (VisualRT, blank); Response.Flush (); Filter.Position = 0; Var reader = new streamrider (filter, feedback. Content encoding); Return Reader Reed to End (); } Finally {filter.Dispose (); reaction. Filter = old filter; }}  

and use it this way during debug:

  reload public partial visual result () {var result = RenderViewToString ("Index ", ViewData); Back partial view ("index"); Extension method for spark :  
  public static string RenderSparkToString (this control controller, string view name, object view data) {/ code>  

var view = ViewEngines .Engines.FindPartialView (Controller Controller Contains, Visual Name). See; // Create visual footage vs. visual view = new viewfinder (controller Controller Contax, View, Controller Viewdata, Controller.Tempadata); Var sb = new stringbiller (); Var Writer = New String Vter (SB); ViewContext.View.Render (viewContext, author); Writer.flush (); Return sb.ToString (); }


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -