you mention you are not familiarized with the ASP.NET, so, maybe this excelent article from Rick can help you as it as a full article on how to block IP's and even have an admin area to manage them...
You can get the IP address of the client using the HttpRequest.UserHostAddress property (an instance can be accessed using this.Request from any page or using static property HttpContext.Current).
As far as I know, there is no standard method that would compare the IP address with a specified range, so you'll need to implement this bit yourself.
You'll probably want to check this for every request, which can be done either in the OnInit method of every page (that you want to block) or in the BeginRequest event of the application (typically in Global.asax).
If you detect a blocked address, you can output an empty (placeholder) page using Server.Transfer method (Response.End would be another alternative, but that simply cuts the page - returning an empty page, while Server.Transfer allows you to output some message to the client).
If what you mean by "block" is "don't let them harass my server", this is not an asp.net issue, you need a firewall (software or hardware).
If what you mean by "block" is "don't show my pages":
' pseudocode, I haven't checked the exact syntax
Sub Page_Load()
If HttpRequest.UserHostAddress = "123.123.123.1" then
Response.Redirect "404.htm" ' send them elsewhere
end if
End Sub
you mention you are not familiarized with the ASP.NET, so, maybe this excelent article from Rick can help you as it as a full article on how to block IP's and even have an admin area to manage them...
You can get the IP address of the client using the
HttpRequest.UserHostAddress
property (an instance can be accessed usingthis.Request
from any page or using static propertyHttpContext.Current
).As far as I know, there is no standard method that would compare the IP address with a specified range, so you'll need to implement this bit yourself.
You'll probably want to check this for every request, which can be done either in the
OnInit
method of every page (that you want to block) or in theBeginRequest
event of the application (typically inGlobal.asax
).If you detect a blocked address, you can output an empty (placeholder) page using
Server.Transfer
method (Response.End
would be another alternative, but that simply cuts the page - returning an empty page, whileServer.Transfer
allows you to output some message to the client).If what you mean by "block" is "don't let them harass my server", this is not an asp.net issue, you need a firewall (software or hardware).
If what you mean by "block" is "don't show my pages":