C#ASP.net测试,如果用户是来自本地网络 [英] C# ASP.net Test if user comes from Local Network

查看:139
本文介绍了C#ASP.net测试,如果用户是来自本地网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C#/ ASP.net找出用户在浏览该网站是否在同一个网络上,因此某些链接仅显示在办公室(那些谁有权访问它们)。

任何人从办公室内访问将要把它做这样的本地IP地址(即192.168.x.x),而外部用户将浏览到公共域名。

所有我需要的是某种方式两种类型的用户区分开来。


解决方案

 如果(Request.UserHostAddress.StartsWith(192.168))
{
    //为localuser
}

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.

解决方案

if (Request.UserHostAddress.StartsWith("192.168"))
{
    //localuser
}

这篇关于C#ASP.net测试,如果用户是来自本地网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆