asp.net mvc - How could I render a view containing custom display templates into a compiled view? -




my mvc view makes calls html.displayfor() , display templates within make calls other html.displayfor(). i need render type of view contains custom display templates string, wrote method this:

public static string renderrazorview(dynamic model, string viewpath, httpcontextbase httpcontextbase) {     using (var sw = new stringwriter())     {        viewdatadictionary viewdata = new viewdatadictionary();        viewdata.model = model;         controllercontext controllercontext = new controllercontext(new requestcontext(httpcontextbase, routetable.routes.getroutedata(httpcontextbase)),  new tempcontroller());             razorview view = new razorview(controllercontext, viewpath, null, false, null);             view.render(new viewcontext(controllercontext, view, viewdata, new tempdatadictionary(), sw), sw);             return sw.getstringbuilder().tostring();         }     } 

and called in way:

var bookdisplay = new bookdisplaymodel(model);     var data = renderrazorview(bookdisplay,          $"~/themes/admin/theme1/views/book/preview.cshtml", utilities.gethttpcontextbase(siteuri/admin"))); 

it seems renderview() , render() method in razorview class using default display templates , rendering custom display templates doesn't occur.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -