我有一个站点显示需要在另一个站点上显示的html内容(第一个站点是内容管理系统的前端)。你如何从URL中获取html?
所以站点1页= http://site1/pagecontent
和现场2(http://site2/pagecontent)我需要能够显示站点1页上显示的内容。
我正在使用.Net C#(MVC),并不想只使用iframe。
有没有办法将html吸入字符串变量?
我有一个站点显示需要在另一个站点上显示的html内容(第一个站点是内容管理系统的前端)。你如何从URL中获取html?
所以站点1页= http://site1/pagecontent
和现场2(http://site2/pagecontent)我需要能够显示站点1页上显示的内容。
我正在使用.Net C#(MVC),并不想只使用iframe。
有没有办法将html吸入字符串变量?
是的,你可以使用WebClient类:http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx
WebClient wClient = new WebClient();
string s = wClient.DownloadString(site2);
当然。请参阅System.Net.WebClient
类,特别是DownloadString()
方法。