简体   繁体   English

如何从aspx页面调用任何URL?

[英]How to call any url from aspx page?

I have one .aspx page and inside that page I want to call third party url and I should include the content from that url. 我有一个.aspx页面,并且在该页面中我想调用第三方URL,并且应该包括该URL中的内容。 I can achive this by using iframe but i am restricted to not to use iframe. 我可以通过使用iframe来实现这一点,但仅限于不使用iframe。

Ex: 例如:

    <body>
         my content ......
         ..................
         <Video><url="www.yamaha.com\learnPiano">  Thirdparty video get played here      </url>           </Video>
         .................
          ..................... my content .... 
    </body>

查看WebRequest和WebResponse。

You can do this on the server side. 您可以在服务器端执行此操作。 Add an ASP:Literal control to your page and name it "OtherContent" for example. 例如,将ASP:Literal控件添加到您的页面并将其命名为“ OtherContent”。

var webRequest = WebRequest.Create("http://www.google.com");
var webResponse = webRequest.GetResponse();
if (webResponse != null)
{
  var responseStream = webResponse.GetResponseStream();
  if (responseStream != null)
  {
    var streamReader = new StreamReader(responseStream);
    var pageSource = streamReader.ReadToEnd();
    OtherContent.Text = pageSource;
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM