Click here to Skip to main content
15,905,071 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello,

This could be weird and I haven't done anything like this before. I am creating a web application with ASP.Net C# and I have a situation that I need to prevent users from accessing some pages from WAN (e.g. http://www.mysite.com/lanOnlyPages.aspx) because we can't let user to perform some operation remotely. We put our IIS web server at the office and I only want for those users who are currently at office to access those pages. When they go back home and access those pages, I don't want them to access. And this need to be done inside my application.

First I planned to save web server LAN IP in the database and compare 1st 3 parts of client LAN IP. But server can be 192.168.1.xxx and client can also be 192.168.1.xxx, so, it does not work. Which IP should I check to
compare? Or is there any easy way to achieve this?

Thanks in advanced,
tslin
Posted
Comments
Client IP would change when machine goes out of the office network. So that can't access the app.
tslin89 10-Mar-15 23:53pm    
Thanks for the reply. What do you mean by "can't access the app"?
That means the client cannot be able to access the application.

1 solution

It sounds bad safety practice to me. Safety is safety, it should not depend on location of the user. It's better when access to safety-sensitive data is based on secure authentication; if some people leave the office permanently (resign from work, for example), you can revoke the user profile record. However, you decide.

You can always checkup the client IP in all the HTTP requests: https://msdn.microsoft.com/en-us/library/system.web.httprequest.userhostaddress%28v=vs.110%29.aspx[^].

Based on the IP, you can figure out that the user sends the request from the office and give this person additional privileges, denying them in all other cases.

—SA
 
Share this answer
 
Comments
tslin89 11-Mar-15 0:03am    
Thanks for the reply. I understand that and user's profile will be revoked when they resigned or left the company as a normal procedure.

My situation is similar to Goods refund in POS System. They need to receive the goods from customer and proceed refund operation. They shouldn't able to do that refund from other places. Normally, it can be done by using Windows Based application connecting to database from LAN or web based application hosted in intranet. But we are using web based and also some pages need to be accessed through WAN.

And thanks for the advice. I will check HttpRequest from provided link and continue.
Sergey Alexandrovich Kryukov 11-Mar-15 0:18am    
As I say, you decide. The check I suggested may suite you. Anyway, check it out and consider accepting my answer formally.
—SA

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