我想獲取域名而不是遠程ip。我有兩個域(網站)。例如www.a1.com和www.a2.com。在A2域發送請求至A1域的頁面一樣GetRequest.ashx在通用處理頁面中使用asp.net獲取域名
HTTP請求的例子是
http://www.a1.com/GetRequest.ashx?username=bala&password=123456
我GetRequest.ashx頁例如編碼
<%@ WebHandler Language="VB" Class="Handler" %>
Imports System
Imports System.Web
Public Class GetRequest : Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/plain"
Dim username As String = context.Request.QueryString("username")
Dim password As String = context.Request.QueryString("password")
**'//Here i need a coding to get requested domain name that is who send the request to my page**
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property
End Class
我已經使用
以下編碼但不能解決我的問題。因爲它返回的是IP地址。我需要域名而不是IP。
context.Request.ServerVariables("REMOTE_ADDR")
context.Request.ServerVariables("REMOTE_HOST")
Dim domain As String
Dim url As Uri = HttpContext.Current.Request.Url
domain = url.AbsoluteUri.Replace(url.PathAndQuery, String.Empty)
可變域包含www.a1.com,但我需要www.a2.com
使用谷歌分析的API來解決我的問題?那麼如何使用這個API可以在任何一個解釋
請告訴我你真的在傳輸線上傳遞純文本用戶名/密碼。 – Eonasdan
只是例如 –
好。我擔心所有的SO都會因爲那個而打你:) – Eonasdan