473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Block Ip in asp.net

hi friends
I am making a website in asp.net c# code behind. My client told me that he want to remove the user who break the website law and then that particular user can create another account in our site with different emailid and password.
I am little bit confused what to do.
Thanks in advance
Monish Solanki
Mar 29 '10 #1
7 3861
Frinavale
9,735 Expert Mod 8TB
If you prevent an IP from accessing your website you can run into problems because sometimes many people will share the same IP.

For example, say you have a university where many students are connected to a LAN which is connected to the Internet. Any university students that connect to your website will be connected using the same IP: the university's IP.

If you block this IP then many people will be blocked from your site. This is why many websites block users instead of IP addresses.

It's a lot of work cleaning up after people who are abusing your website but that's part of the job.


Now, that being said, you can detect the IP of the user that is connected to your website using the Request.UserHostAddress. This contains the IP address of the user connected to your webpage.

For example:
Expand|Select|Wrap|Line Numbers
  1. string ip_address = Request.UserHostAddress;
Happy coding!

-Frinny
Mar 29 '10 #2
Thanks Frinivale
But what about the dyanamic ip? I have upload the below code
Expand|Select|Wrap|Line Numbers
  1.  string VisitorsIPAddr = string.Empty;
  2.         //Users IP Address.                
  3.         if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
  4.         {
  5.             //To get the IP address of the machine and not the proxy
  6.             VisitorsIPAddr = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
  7.         }
  8.         else if (HttpContext.Current.Request.UserHostAddress.Length != 0)
  9.         {
  10.             VisitorsIPAddr = HttpContext.Current.Request.UserHostAddress;
  11.         }
I get correct IP but when i disconnect the internet and reconnect it again i get different ip because my ip is not static it's dynamic ip.
Mar 30 '10 #3
Frinavale
9,735 Expert Mod 8TB
Oh yeah, I forgot about that reason for why you shouldn't block by IP address :)

You can't fix this...this is just how things are.

-Frinny
Mar 30 '10 #4
So is there any solution MR Frinavale. Can i get some unique thing from client computer that remain unique in all the request.
Can I get something unique from client side using javascript?
Thanks in advance
Monish
Mar 31 '10 #5
Frinavale
9,735 Expert Mod 8TB
JavaScript wont help you...
I'm not sure if there's a better way to do this.

I honestly think that blocking the user is the best solution (it's what we do here on bytes). Eventually they will get the hint.
Mar 31 '10 #6
CroCrew
564 Expert 512MB
Hello Monish30,

I have been following this post and held off on posting my comments. First off Frinavale is spot on with the first reply post to your question.

There have been many attempts/implementations of blocking “banned users” from websites. There is no “easy” way on administrating users that abuse a website. Identifying a banded user is next to impossible.

I know that you’re pressing to find an alternative “easy” way of administrating users that abuse your website. Before you even ask about using MAC address as an identifier don’t. MAC address are not routed beyond the user's local network so there is no way for you to see it from a remote machine. Even if you create an ActiveX control and embedded on your page the user would get a warning popup that they would have to install this potentially unsafe control before it would work. ActiveX will also not work on non-IE browsers without another special plugins that will require user install.

Other things to think about:
1) MAC address can be spoofed.
2) Network card can be changed.
3) User can go to a different machine.
4) User can create a new account.
5) IP is shared between computers.

As you can see there are too many variables to come up with an “easy” solution.

When the web standards were being developed, the designers went to great lengths to ensure that web visitors could only be repeatedly identified at their own choice. Cookies are the standard way to identify repeat visitors, but the visitors have been given the right to clear them at any time or not accept them at all if that is their preference.

If the fraudulent activities of your website are of very high priority to block, you should block the IP address and then investigate if the IP is shared between users. Remove the block after a period of time and monitor to see if the fraudulent activity begins again.

You can take it a step further by adding other layers:
1) Force people to login to your website and ban fraudulent activity on IP and login.
2) Force users to provide email address when signing up for an account and only allow unique email to sign up for an account.
3) When allowing a update/post to your forum send a conformation email to the email address at signup asking them to verify that they want to post what they wrote by clicking on a link within the email.

The key is to make it harder for people to deface your website but still easy to use.

Good luck,
CroCrew~
Mar 31 '10 #7
Frinavale
9,735 Expert Mod 8TB
Thanks for re-iterating CroCrew, that is a much better response than mine!

:)
Mar 31 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
4
by: Christopher | last post by:
This should be a quick one. URL: http://cfa-www.harvard.edu/~cpilman/Stuff/flush.html Code: ============================= <!DOCTYPE HTML Public "-//W3C//DTD HTML 4.01//EN">...
2
by: TadPole | last post by:
Hi all, My main problems are::::::::: 1. Set a value within a block container that can be used and changed by subsequent templates/block-containers/tables etc.. 2. get/determine/find the...
7
by: seamoon | last post by:
Hi, I'm doing a simple compiler with C as a target language. My language uses the possibility to declare variables anywhere in a block with scope to the end of the block. As I remembered it this...
2
by: morrell | last post by:
I have a request to find out is there an easy way to solve this little poblem. ___________________ | Block 1 | | | | | | |...
6
by: foolmelon | last post by:
If a childThread is in the middle of a catch block and handling an exception caught, the main thread calls childThread.Abort(). At that time a ThreadAbortException is thrown in the childThread. ...
8
by: Alvin | last post by:
I'm making a very simple game in SDL, and I'm not asking for SDL help I hope - this looks like something C++ related, so I'll ask here. I have a class for a simple block, or tile, in the game,...
6
by: dave8421 | last post by:
Hi, I'm a bit confused about the definition about "Prinicpal Block Boxes" in CSS 2.1 draft specification. ( http://www.w3.org/TR/2006/WD-CSS21-20061106 ) <pre> 9.2.1 Block-level elements and...
2
by: Bob Greschke | last post by:
This is the idea Block = pack("240s", "") Block = pack(">H", W) Block = pack(">H", X) Block = pack(">B", Y) Block = pack(">H", Z)) but, of course, Block, a str, can't be sliced. The real...
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.