how to block certain ip's (users) to access my website?
anybody knows of blocking ce开发者_Go百科rtain users (by IP) from accessing your website (website on asp.net mvc).
EDIT: I know that web-servers can do this as well, but I need this at the application level
It's better to do this in the web server.
However, if you want to do it in code, you can handle the Application.BeginRequest
event, check Request.UserHostAddress
, and call Response.End
.
IIS allows you to specify IP-based block lists.
If you want to do it at the application level you can get the users IP from Request.UserHostAddress and then do a redirect to wherever you want them to go if their IP is in a list you have saved.
精彩评论