How to call Html.Partial()
method from controller or some other method in external class library?
I need something like:
string someView = "SomeView";
object someModel = new SomeModel();
HtmlHelper helper = new HtmlHelper();
string html = helper.Partial(someView, someModel).ToString();
I need to get html string which this method returns.
If you want to render partial view to string you can use this link: Render a view as a string
But i think you doing something wrong...
you need to use WebClient for download the html page, something like that:
string viewUrl = Url.RouteUrl(new { Controller = "Pages", Action = "Index" });
WebClient client = new WebClient();
client.Encoding = Encoding.UTF8;
string result = client.DownloadString(new Uri(viewUrl ));
then you will get the page's html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.