Possible Duplicate:
How to check in ASP.NET MVC View if site is running on localhost or 127.0.0.1
I am using two entry for connection string in web.config, and i am using HttpContext.Current.Request.UserHostAddress for detection between deployment and development environment:
public static SqlConnection GetSqlConnection()
{
if (HttpContext.Current.Request.UserHostAddress != "127.0.0.1")
...
else
...
}
but problem is here, some times HttpContext.Current is null and raise exception (i.e: when scheduled task is runed in asp.net from global.asax). is there any general solution for this?