How To Setup Base Controller Or Entrance Gate

Hi

I wanna put a Entrance gate for the site: To check some items for example username & IP to see if it’s valid to enter the site. Then do some special configurations according the user status.

After that, exect the user request (is mean exect the Controller/action in the user’s URL after executting these primary codes).

But I don’t know how to set up this Enterance gate. Or where we can put this primary codes?

Take a look here