ASP.Net/Server/Server Variables — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 11:53, 26 мая 2010
All Request Server Variables (VB.net)
<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
Dim NameArray() As String
Dim VisitorSV As NameValueCollection
Dim I as Integer
VisitorSV = Request.ServerVariables
NameArray = VisitorSV.AllKeys
For I = 0 To UBound(NameArray)
lblMessage.Text = lblMessage.Text _
& NameArray(I) & ": " _
& VisitorSV.Item(I) & "<BR>"
Next
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Server Variables Page</TITLE>
</HEAD>
<BODY LEFTMARGIN="40" TOPMARGIN="30">
<form runat="server">
<asp:Label
id="lblMessage"
runat="Server"
/>
</Form>
</BODY>
</HTML>
Get all server variables (VB.net)
<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
Dim NameArray() As String
Dim VisitorSV As NameValueCollection
Dim I as Integer
VisitorSV = Request.ServerVariables
NameArray = VisitorSV.AllKeys
For I = 0 To UBound(NameArray)
If NameArray(I) <> "ALL_HTTP" and _
NameArray(I) <> "ALL_RAW" Then
lblMessage1.Text = lblMessage1.Text _
& NameArray(I) & ": " _
& VisitorSV.Item(I) & "<BR>"
End If
Next
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Server Variables Sample Page</TITLE>
</HEAD>
<BODY >
<form runat="server">
<Font Face="Tahoma">
<asp:Label
id="lblMessage1"
runat="Server"
Font-Bold="True"
FOnt-Size="9"
/>
</Font>
</Form>
</BODY>
</HTML>
Request Server Variables Item(REMOTE_ADDRESS) (VB.net)
<%@ Page Language="vb" %>
<html>
<head>
<title>Request property example</title>
<script runat="server">
Sub Page_Load()
Message.Text = "The current request is from: " & _
CStr(Request.ServerVariables.Item("REMOTE_ADDRESS"))
End Sub
</script>
</head>
<body>
<asp:label id="Message" runat="server"/>
</body>
</html>