新手.NET的问题 - 变量就是相当于$ _SESSION ['SERVER_NAME']变量、新手、问题、NET

2023-09-06 06:38:33 作者:一生无味

我还是新的。NET ....我试图发现打印出一个aspx.cs文件,目前正在执行该域名的变量。我来自PHP的土地,它有$ _ SERVER ['SERVER_NAME']或$ _ SERVER ['HTTP_HOST']。什么是.NET相当于这些变量?

I'm still new to .net....I'm trying to find the variable that prints the domain name that an aspx.cs file is currently executing from. I come from PHP land, and it has $_SERVER['SERVER_NAME'] or $_SERVER['HTTP_HOST']. What's the .net equivalent for those variables?

感谢

推荐答案

您都在:

HttpContext.Current.Request.Url

在你的领域,绝对URI,AbsolutePath,等该对象,请参阅的这个问题和此链接为更多的参考资料

In that object you have the Domain, AbsoluteUri, AbsolutePath, etc. Please see this question and this link for more references