簡體   English   中英

如何在C#中獲取具有自定義域名的當前PathName?

[英]How do I get the current PathName with a custom domain name in C#?

我正在嘗試生成指向我的應用程序的邀請鏈接。

鏈接必須是用戶正在瀏覽的確切域名,即http://www.mycompany.com.br/,但是當我嘗試這樣做時:

HttpContext.Current.Request.Url.Scheme+"://"+HttpContext.Current.Request.Url.Host+"/SignUp/"

它返回以下內容: http : //mycompany.azurewebsites.net/SignUp/而不是自定義DNS名稱: http : //www.mycompany.com.br/SignUp/

您可以使用以下代碼獲取http://www.mycompany.com.br/

string strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
string strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM