I need to secure access to all pages in a .NET webapp – EXCEPT requests from:
- local network (the network IIS is running on)
- IPs listed/netmasks listed in a database
all other requesets should be redirected to a login form
I was thinking in the direction of a HttpModule – but never wrote one.
Can anyone provide any ideas to this?
Thank you!
Using a HttpModule would be the best way to do this. You could use this to catch any requests before the page executes and redirect to the login form if required.
You’ll also need to modify web.config and add a reference to the module:
This code would also need some modification to ensure that users who are logged in are not redirected back to the login page, but it should be enough to get you started.