views:

25

answers:

2

I want to use C#/ASP.net to find out whether the user browsing the website is on the same network so that certain links are only displayed while in the office (to those who have access to them).

Anyone accessing from within the office will be doing so by going to it's local IP address (i.e. 192.168.x.x) whereas external users will be browsing to the public domain name.

All I need is some way to differentiate between the two types of user.

A: 

Take a look @ Request.Url.Host - you'll be able to pluck the address from this.

Will A
Any suggestions on the best way of checking whether a Url is local?
Tuskan360
`Request.Url.Host.StartsWith("192.168")` - lifted from Simon's response below.
Will A
+1  A: 
if (Request.UserHostAddress.StartsWith("192.168"))
{
    //localuser
}
Simon Hazelton
Remember host address can be spoofed.
ggonsalv