newbie .net question - variable that's equivalent of $_SESSION['SERVER_NAME']

女生的网名这么多〃 提交于 2019-12-24 01:27:51

问题


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


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/5710906/newbie-net-question-variable-thats-equivalent-of-sessionserver-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!