ASP.Net/Request/URI URL

Материал из .Net Framework эксперт
Версия от 11:53, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Uri for current page (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim TheRef As Uri 
    TheRef = Request.UrlReferrer
    lblMessage1.Text = _
        "Port: " & TheRef.Port & "<BR>" _
        & "Path: " & TheRef.AbsolutePath & "<BR>" _
        & "Protocol: " & TheRef.Scheme & "<BR>" _
        & "User Agent: " & Request.UserAgent & "<BR>" _
        & "User Host Address: " & Request.UserHostAddress & "<BR>" _
        & "User Host Name: " & Request.UserHostName & "<BR>"  
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>URI Sample Page</TITLE>
</HEAD>
<BODY >
<form runat="server">
<Font Face="Tahoma">
<asp:Label
    id="lblMessage1"
    runat="Server"
    Font-Bold="True"
/>
</Font>
</Form>
</BODY>
</HTML>



URL Encoding (VB.net)

<%@ Page Language="VB" %>
<html>
   <head>
      <title>URLEncoding</title>
   <script runat="server">
      Sub Page_Load()
         If IsPostBack
            Response.Write(Server.UrlEncode(Request.Form("name")))
         End If
      End Sub
   </script>
   </head>
<body>
<%--    <form id="form1" action="UrlEncode.aspx"  method="POST" runat="server">
 --%>
   <form id="form1" method="POST" runat="server">
      <h3>Name:</h3>
      <input type="text" id="name" runat="server">
      <input type="submit" runat="server">
   </form>
</body>
</html>



Url Referrer: scheme (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim TheRef As Uri 
    TheRef = Request.UrlReferrer
    lblMessage.Text = "You connected to this page " _
        & "from this page: " & TheRef.AbsolutePath _
        & "<BR>Using this protocol: " _
        & TheRef.Scheme
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Referrer Information</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblMessage" 
    font-size="12pt"
    font-name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>



Url Referrer: your path (VB.net)

<%@ Page Language=VB Debug=true %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim TheRef As Uri 
    TheRef = Request.UrlReferrer
    lblMessage.Text = "You connected to this page " _
        & "from this page: " & TheRef.AbsolutePath _
        & "<BR>Using this protocol: " _
        & TheRef.Scheme
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Referrer Information</TITLE>
</HEAD>
<form runat="server">
<asp:label 
    id="lblMessage" 
    font-size="12pt"
    font-name="Tahoma"
    runat="server"
/>
</form>
</BODY>
</HTML>