本文介绍了如何获得外部网页上的asp.net内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要得到一个页面的内容(这只是一个形象)如但只有IP:22.22.22.22访问该文件。因此,我需要能够从我的pics.aspx文件做的另一台服务器上如

到目前为止,我有低于这个脚本,它可以得到?code = 33 。现在我所要做的就是找​​回 子项(计数器2)。我曾与PHP在过去的工作,所以我不知道我在用ASP做的事。如果你能指导我如何通过其URL检索另一个网页的内容一点,这将是更AP preciated :)

 <%@页面语言=VB%GT;
< HTML和GT;
   < HEAD>
      <标题>通过QueryString集合在ASP.NET&LT显示查询字符串值; /标题>
   < /头>
<身体GT;
<%
暗淡计数器1,计数器2作为整数
昏暗的键(),子()作为字符串
昏暗MyQueryStringCollection作为的NameValueCollectionMyQueryStringCollection =的Request.QueryString键= MyQueryStringCollection.AllKeys
对于计数器1 = 0到Keys.GetUpperBound(0)
 子项= MyQueryStringCollection.GetValues​​(C1的)'获得这个键下的所有值。
如果密钥(计数器1)=code接
的Response.Write(计数器&放大器;键(计数器1)及< BR>中和安培;子项(计数器2))
万一
   子项= MyQueryStringCollection.GetValues​​(C1的)'获得这个键下的所有值。
   对于计数器2 = 0到subKeys.GetUpperBound(0)
      '的Response.Write(价值&放大器; CStr的(C2的)及:&放大器;子项(C2的)及< BR>中)
   接下来计数器2
接下来计数器1
%GT;
< /身体GT;
< / HTML>


解决方案

看看的的和的类。他们将可以请求其他页面的内容。这则取决于你要如何显示的响应。

。希望得到的,你的轨道上。

I need to get the contents of a page (which is just an image) like http://11.11.11.11/code.aspx?product=33 but only ip:22.22.22.22 has access to that file. Therefore I need to be able to do it from my pics.aspx file on another server like http://22.22.22.22/pics.aspx?code=33

So far I have this script below, which can get the ?code=33. Now all I have to do is retrieve the contents of http://11.11.11.11/code.aspx?product=subKeys(Counter2). I have worked with PHP in the past so I don't know what I'm doing with asp. if you could guide me a little on how to retrieve contents of another page via its url, it would be much appreciated :)

<%@ Page Language="vb" %>
<html>
   <head>
      <title>Showing QueryString values via the QueryString Collection in ASP.NET</title>
   </head>
<body>


<%
Dim Counter1, Counter2 As Integer
Dim Keys(), subKeys() As String
Dim MyQueryStringCollection As NameValueCollection

MyQueryStringCollection=Request.QueryString

Keys = MyQueryStringCollection.AllKeys
For Counter1 = 0 To Keys.GetUpperBound(0)
 subKeys = MyQueryStringCollection.GetValues(Counter1) ' Get all values under this key.
If Keys(Counter1)="code" Then
Response.Write("Counter is "& Keys(Counter1) & "<br>" & subKeys(Counter2))
End If
   subKeys = MyQueryStringCollection.GetValues(Counter1) ' Get all values under this key.
   For Counter2 = 0 To subKeys.GetUpperBound(0)
      ' Response.Write("Value " & CStr(Counter2) & ": " & subKeys(Counter2) & "<br>")
   Next Counter2
Next Counter1
%>


</body>
</html>
解决方案

Take a look at the WebRequest and WebResponse classes. They will allow you to request the contents of other pages. It's then up to you how you want to display the response.

Hope that get's you on track.

这篇关于如何获得外部网页上的asp.net内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 07:11