By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

How to check if browser is running on the web server?

P: n/a
I am part of a group that has developed an ASP.Net web application. I
am looking for a way to determine whether or not the browser is
actually running on the web server. For this case (when executing IE
on the webserver) I want to remove a link to Remote Desktop -- as the
desktop is NOT remote in this case, and I believe doesn't work
attempting remote access to one's self. I wrote the following code to
check the "browser on server" condition and it works fine, as long as
I have a DNS server:
public static bool CheckBrowserOnServer()
{
bool foundIPmatchFlag = false; // Assume no match
string userhost= HttpContext.Current.Request.UserHostAddress;
string serverhost = Dns.GetHostName(); // get name of server
IPHostEntry ipserverhost = Dns.GetHostByName(serverhost);
IPAddress[] addresses = ipserverhost.AddressList; // get list
// Look for an IP address match
foreach ( IPAddress address in addresses )
{
if (userhost == address.ToString())
{
foundIPmatchFlag = true; // got a match
break;
}
}
return foundIPmatchFlag;

Would anyone know how to accomplish the same thing in an environment
WITHOUT DNS? Ideally I'd like to have my test be server-side, but I'd
certainly consider client-side logic (i.e. Javascript) that could
achieve the same ends.

Thanks in advance,
Michael Rose
Unisys Corp
Jul 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Michael

If I understand you correctly, I think you can just use the Process class
and check for iexplore.exe and if it's running, either kill it or do what
you want. You can check for other browsers too if you need it finely
grained

"Dr. StrangeDub" <st********@yahoo.com> wrote in message
news:0g********************************@4ax.com...
I am part of a group that has developed an ASP.Net web application. I
am looking for a way to determine whether or not the browser is
actually running on the web server. For this case (when executing IE
on the webserver) I want to remove a link to Remote Desktop -- as the
desktop is NOT remote in this case, and I believe doesn't work
attempting remote access to one's self. I wrote the following code to
check the "browser on server" condition and it works fine, as long as
I have a DNS server:
public static bool CheckBrowserOnServer()
{
bool foundIPmatchFlag = false; // Assume no match
string userhost= HttpContext.Current.Request.UserHostAddress;
string serverhost = Dns.GetHostName(); // get name of server
IPHostEntry ipserverhost = Dns.GetHostByName(serverhost);
IPAddress[] addresses = ipserverhost.AddressList; // get list
// Look for an IP address match
foreach ( IPAddress address in addresses )
{
if (userhost == address.ToString())
{
foundIPmatchFlag = true; // got a match
break;
}
}
return foundIPmatchFlag;

Would anyone know how to accomplish the same thing in an environment
WITHOUT DNS? Ideally I'd like to have my test be server-side, but I'd
certainly consider client-side logic (i.e. Javascript) that could
achieve the same ends.

Thanks in advance,
Michael Rose
Unisys Corp


--
W.G. Ryan MVP Windows - Embedded

http://forums.devbuzz.com
http://www.knowdotnet.com/dataaccess.html
http://www.msmvps.com/williamryan/
Jul 21 '05 #2

P: n/a
Thanks for the input, but I think you misread my question -- or I
phrased it badly. I don't want to know if these is an IExplore.exe
processing running on the web server machine, I want to know if I
(i.e., the browser accessing the ASP.Net app) am remote or not? That
is, where is the browser running the app from - a remote client or
right on the machine hosting the website?

-Michael Rose

On Thu, 24 Jun 2004 00:19:08 -0400, "William Ryan eMVP"
<do********@comcast.nospam.net> wrote:
Hi Michael

If I understand you correctly, I think you can just use the Process class
and check for iexplore.exe and if it's running, either kill it or do what
you want. You can check for other browsers too if you need it finely
grained

"Dr. StrangeDub" <st********@yahoo.com> wrote in message
news:0g********************************@4ax.com.. .
I am part of a group that has developed an ASP.Net web application. I
am looking for a way to determine whether or not the browser is
actually running on the web server. For this case (when executing IE
on the webserver) I want to remove a link to Remote Desktop -- as the
desktop is NOT remote in this case, and I believe doesn't work
attempting remote access to one's self. I wrote the following code to
check the "browser on server" condition and it works fine, as long as
I have a DNS server:
public static bool CheckBrowserOnServer()
{
bool foundIPmatchFlag = false; // Assume no match
string userhost= HttpContext.Current.Request.UserHostAddress;
string serverhost = Dns.GetHostName(); // get name of server
IPHostEntry ipserverhost = Dns.GetHostByName(serverhost);
IPAddress[] addresses = ipserverhost.AddressList; // get list
// Look for an IP address match
foreach ( IPAddress address in addresses )
{
if (userhost == address.ToString())
{
foundIPmatchFlag = true; // got a match
break;
}
}
return foundIPmatchFlag;

Would anyone know how to accomplish the same thing in an environment
WITHOUT DNS? Ideally I'd like to have my test be server-side, but I'd
certainly consider client-side logic (i.e. Javascript) that could
achieve the same ends.

Thanks in advance,
Michael Rose
Unisys Corp


Jul 21 '05 #3

P: n/a
Note: local access uses IP address 127.0.0.1 and/or the name "localhost" in
the URL.

In addition, if the user doesn't have DNS, then they are either using WINS
to resolve the address or they are typing IP addresses. The latter is
fairly unlikely.
With WINS, the name in the URL will match the machine name for the web
server.

So, look for the machine name, localhost, or the local IP address
(127.0.0.1) and you should cover the bases fairly well.

--- Nick

"Dr. StrangeDub" <st********@yahoo.com> wrote in message
news:87********************************@4ax.com...
Thanks for the input, but I think you misread my question -- or I
phrased it badly. I don't want to know if these is an IExplore.exe
processing running on the web server machine, I want to know if I
(i.e., the browser accessing the ASP.Net app) am remote or not? That
is, where is the browser running the app from - a remote client or
right on the machine hosting the website?

-Michael Rose

On Thu, 24 Jun 2004 00:19:08 -0400, "William Ryan eMVP"
<do********@comcast.nospam.net> wrote:
Hi Michael

If I understand you correctly, I think you can just use the Process class
and check for iexplore.exe and if it's running, either kill it or do what
you want. You can check for other browsers too if you need it finely
grained

"Dr. StrangeDub" <st********@yahoo.com> wrote in message
news:0g********************************@4ax.com.. .
I am part of a group that has developed an ASP.Net web application. I
am looking for a way to determine whether or not the browser is
actually running on the web server. For this case (when executing IE
on the webserver) I want to remove a link to Remote Desktop -- as the
desktop is NOT remote in this case, and I believe doesn't work
attempting remote access to one's self. I wrote the following code to
check the "browser on server" condition and it works fine, as long as
I have a DNS server:
public static bool CheckBrowserOnServer()
{
bool foundIPmatchFlag = false; // Assume no match
string userhost= HttpContext.Current.Request.UserHostAddress;
string serverhost = Dns.GetHostName(); // get name of server
IPHostEntry ipserverhost = Dns.GetHostByName(serverhost);
IPAddress[] addresses = ipserverhost.AddressList; // get list
// Look for an IP address match
foreach ( IPAddress address in addresses )
{
if (userhost == address.ToString())
{
foundIPmatchFlag = true; // got a match
break;
}
}
return foundIPmatchFlag;

Would anyone know how to accomplish the same thing in an environment
WITHOUT DNS? Ideally I'd like to have my test be server-side, but I'd
certainly consider client-side logic (i.e. Javascript) that could
achieve the same ends.

Thanks in advance,
Michael Rose
Unisys Corp

Jul 21 '05 #4

P: n/a
Thanks Nick (and others) for your input.

I think the localhost part of Nick's answer matches what we ended up
doing.

-Michael Rose
Unisys Corp

On Sat, 26 Jun 2004 17:58:47 GMT, "Nick Malik"
<ni*******@hotmail.nospam.com> wrote:
Note: local access uses IP address 127.0.0.1 and/or the name "localhost" in
the URL.

In addition, if the user doesn't have DNS, then they are either using WINS
to resolve the address or they are typing IP addresses. The latter is
fairly unlikely.
With WINS, the name in the URL will match the machine name for the web
server.

So, look for the machine name, localhost, or the local IP address
(127.0.0.1) and you should cover the bases fairly well.

--- Nick

"Dr. StrangeDub" <st********@yahoo.com> wrote in message
news:87********************************@4ax.com.. .
Thanks for the input, but I think you misread my question -- or I
phrased it badly. I don't want to know if these is an IExplore.exe
processing running on the web server machine, I want to know if I
(i.e., the browser accessing the ASP.Net app) am remote or not? That
is, where is the browser running the app from - a remote client or
right on the machine hosting the website?

-Michael Rose

On Thu, 24 Jun 2004 00:19:08 -0400, "William Ryan eMVP"
<do********@comcast.nospam.net> wrote:
>Hi Michael
>
>If I understand you correctly, I think you can just use the Process class
>and check for iexplore.exe and if it's running, either kill it or do what
>you want. You can check for other browsers too if you need it finely
>grained
>
>"Dr. StrangeDub" <st********@yahoo.com> wrote in message
>news:0g********************************@4ax.com.. .
>> I am part of a group that has developed an ASP.Net web application. I
>> am looking for a way to determine whether or not the browser is
>> actually running on the web server. For this case (when executing IE
>> on the webserver) I want to remove a link to Remote Desktop -- as the
>> desktop is NOT remote in this case, and I believe doesn't work
>> attempting remote access to one's self. I wrote the following code to
>> check the "browser on server" condition and it works fine, as long as
>> I have a DNS server:
>> public static bool CheckBrowserOnServer()
>> {
>> bool foundIPmatchFlag = false; // Assume no match
>> string userhost= HttpContext.Current.Request.UserHostAddress;
>> string serverhost = Dns.GetHostName(); // get name of server
>> IPHostEntry ipserverhost = Dns.GetHostByName(serverhost);
>> IPAddress[] addresses = ipserverhost.AddressList; // get list
>> // Look for an IP address match
>> foreach ( IPAddress address in addresses )
>> {
>> if (userhost == address.ToString())
>> {
>> foundIPmatchFlag = true; // got a match
>> break;
>> }
>> }
>> return foundIPmatchFlag;
>>
>> Would anyone know how to accomplish the same thing in an environment
>> WITHOUT DNS? Ideally I'd like to have my test be server-side, but I'd
>> certainly consider client-side logic (i.e. Javascript) that could
>> achieve the same ends.
>>
>> Thanks in advance,
>> Michael Rose
>> Unisys Corp


Jul 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.