Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can i detect the internet connection type in my Web application
is it a wireless connection or a dial up connection ?

the reason of that question is i need to make an action only users are inside the company now can do it not those who accessing from home throw VPN .
Posted
Comments
Sergey Alexandrovich Kryukov 21-Mar-15 18:55pm    
How knowing if the connection type can help you to figure out if this is through VPN or not? These things are unrelated.
—SA

Please see Solution 1 and my comments to the question and this solution.

You don't need to know what type of connection is used by a client. You need to tell the users connected via VPN from the users connected inside the company.

First of all, VPN uses the IP addressed from its pool, please see, for example:
http://forums.asp.net/p/1356084/2782293.aspx[^],
http://forums.asp.net/t/1356084.aspx?Detecting+VPN+Connection[^].

The answers say "if you know what IP addresses have been allocated to the pool", but you don't even need to know that. It would be simpler to know all the set of IP addresses used to connect from inside the company. You can have configuration file where you support this set. Then you can take IP address from any HTTP request and match it with the required set of IP addressed. Depending on request, deny providing full service for all addressed which don't match it. Here is how:
https://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostaddress%28v=vs.110%29.aspx[^],
http://www.dotnetperls.com/ip[^].

—SA
 
Share this answer
 
Comments
Afzaal Ahmad Zeeshan 21-Mar-15 21:00pm    
+5 for giving the right answer, about the actual question.
Sergey Alexandrovich Kryukov 21-Mar-15 21:06pm    
Thank you, Afzaal.
—SA
Simple answer is that you cannot detect and internet connection type, and furthermore the connection type (or medium used by internet connection) of a client. What?

You should know... ASP.NET passes down only the HTML markup of your application; along with other resources such as images, JavaScript files and CSS style sheets. It has no idea what type of medium a user would be using; wireless internet or a wired. Although using some values of the request headers, it can check for whether it is a mobile device or a computer (or using CSS3 whether a printed page).

But you cannot have a control over the client's machine. You cannot see the transport layer or the physical layer (these are used in Networking as layers[^] in the OSI Model[^]). So, only if you design a software to have a control over the hardware only then you can determine what sort of medium is being used. Because I don't think .NET framework supports such a capability and power for developers to determine network and other devices-based connections. I have never seen anything like that in System.Net namespaces.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Mar-15 19:07pm    
I agree with you, and your explanations are very reasonable, only you are trying to address wrong issue.

It's only the misconception of the inquirer that he needs to know the connection type. The title of the question is simply misleading, you should not have bought it. The real problem for the inquirer is to tell the users connected via VPN from those connected directly from inside of the company. This has nothing to do with "connection type" and can be done. Please see Solution 2.

—SA
Afzaal Ahmad Zeeshan 21-Mar-15 20:59pm    
Oh snap. I did miss that point of him, the VPN.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900