I need to block one IP address or country range IP in asp.net website
Can anyone help me with the code? And how to implement?
I need to block one IP address or country range IP in asp.net website
Can anyone help me with the code? And how to implement?
2
Answers
There’s an example of how you could achieve this in the documentation on the Mircosoft site.
https://learn.microsoft.com/en-us/aspnet/core/security/ip-safelist?view=aspnetcore-5.0
This should give you an idea on how to approach your issue and rework it to suit your own needs.
on the
global.asax
onApplication_BeginRequest
you can check the ip range and if its on your range to block, then stop the processing there (or redirect them to some other page)