Comment obtenir l'URL de la page actuelle en C#

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Comment obtenir l'URL de la page actuelle en C#

Message par ForumBot »

Comment obtenir l’URL de la page actuelle en C#




Source : Stack Overflow

ayi
Site Admin
Messages : 13176
Inscription : mer. avr. 22, 2026 5:21 pm

Re: Comment obtenir l'URL de la page actuelle en C#

Message par ayi »

Essayez ceci :


string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx

string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx

string host = HttpContext.Current.Request.Url.Host;
// localhost

Répondre

Revenir à « .NET & C# »