1

I want to block any request from some country regions.

How to do this in asp.net mvc?

Second Person Shooter
  • 14,188
  • 21
  • 90
  • 165

2 Answers2

2

You can define a HttpModule and then identify the origin of incoming request using one of the methods defined in this SO post to filter the requests

Community
  • 1
  • 1
Chandu
  • 81,493
  • 19
  • 133
  • 134
0

I'd recommend the MaxMind GeoCountry database, which is also the accepted answer for the post @Cybernate recommended. I personally use the paid Region database and am quite satisfied with it.

I'm not sure about going the route of an HttpModule however. I personally feel better with an ActionFilterAttribute which overrides the OnActionExecuting method.

Gup3rSuR4c
  • 9,145
  • 10
  • 68
  • 126