我想知道是否有如果ASP应用程序是在本地运行确定一个推荐的方法。目前我使用Request对象,做一个字符串搜索本地主机或127.0.0.1的服务器变量,但是这有一些限制。最大的一个是该请求对象并不总是可用的,当我需要它。
I want to know if there is a recommended way of determining if an asp application is running locally. At the moment I use the Request object and do a string search for localhost or 127.0.0.1 on the server variable but this has several limitations. The biggest one being that the Request object is not always available when I need it.
请参阅Htt$p$pquest.IsLocal
bool isLocal = HttpContext.Current.Request.IsLocal;