Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net check if using local host

Tags:

c#

asp.net

I would like to know how to check if i am using my localhost, or on the live server.

Basically i would like to have...

if (using localhost)
{
  Do Stuff...
}
else
{
   Do this instead...
}

How would i go about doing this? I have searched around but cant find anything. I would like to do this as i have different settings for the live and the dev servers. And i would like a way to automatically check to see what i am using, and then use certain settings.

Thanks in advance.

like image 706
thatuxguy Avatar asked Nov 29 '22 08:11

thatuxguy


2 Answers

you can try doing something like this

HttpApplication http = new HttpApplication();
if (http.Request.IsLocal)
like image 149
COLD TOLD Avatar answered Dec 17 '22 01:12

COLD TOLD


if(HttpContext.Current.Request.IsLocal)
{
}
like image 25
Alex Z Avatar answered Dec 17 '22 03:12

Alex Z