newbie .net question - variable that's equival

2019-07-22 05:10发布

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?

Thanks

2条回答
做个烂人
2楼-- · 2019-07-22 05:28

Request.ServerVariables["SERVER_NAME"] and Request.ServerVariables["HTTP_HOST"]

查看更多
姐就是有狂的资本
3楼-- · 2019-07-22 05:48

You have all that in:

HttpContext.Current.Request.Url

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

查看更多
登录 后发表回答