C# 在ASMX中获取当前域
在C#中,在asmxweb服务中,如何获取调用web服务的当前域? HttpContext.Current.Request.Url.Host返回我想要的内容,而不是我需要的内容。 我知道我可以把那根绳子剪断,但它看起来真的很优雅。 谢谢这里的帮助:C# 在ASMX中获取当前域,c#,web-services,asmx,C#,Web Services,Asmx,在C#中,在asmxweb服务中,如何获取调用web服务的当前域? HttpContext.Current.Request.Url.Host返回我想要的内容,而不是我需要的内容。 我知道我可以把那根绳子剪断,但它看起来真的很优雅。 谢谢这里的帮助: Request.Url.GetLeftPart(UriPartial.Authority) 在VB.Net中我使用了 With HttpContext.Current.Request.Url sDomain=.Scheme & Sy
Request.Url.GetLeftPart(UriPartial.Authority)
在VB.Net中我使用了
With HttpContext.Current.Request.Url
sDomain=.Scheme & System.Uri.SchemeDelimiter & .Host
End With
或者如果你关心港口的话
With HttpContext.Current.Request.Url
sDomain=.Scheme & System.Uri.SchemeDelimiter & .Host & IIf(.IsDefaultPort,"",":") & .Port
End With
应易于转换为C#) 下面的链接可能重复-你会在这里得到答案。