Question

Are there any prebuilt modules for this? Is there an event thats called everytime a page is loaded? I'm just trying to secure one of my more important admin sections.

Was it helpful?

Solution

As blowdart said, simple IP Address logging is handled by IIS already. Simply right-click on the Website in Internet Information Services (IIS) Manager tool, go to the Web Site tab, and check the Enable Logging box. You can customize what information is logged also.

If you want to restrict the site or even a folder of the site to specific IP's, just go to the IIS Site or Folder properties that you want to protect in the IIS Manager, right click and select Properties. Choose the Directory Security tab. In the middle you should see the "IP Addresses and domain name restrictions. This will be where you can setup which IP's to block or allow.

If you want to do this programatically in the code-behind of ASP.Net, you could use the page preinit event.

OTHER TIPS

A little more information please; do you want to log IPs or lock access via IP? Both those functions are built into IIS rather than ASP.NET; so are you looking for how to limit access via IP programatically?

You can use the following to get a user's IP address:

Request.ServerVariables["REMOTE_ADDR"]

Once you have the IP you will have to write something custom to log it or block by IP. There isn't something built in to asp.net to do this for you.

"Is there an event that's called everytime a page is loaded?"

Page_Load might be what you're looking for.

However, and I'm really not trying to be mean here, if you don't know that, you probably shouldn't be trying to secure the app. You're just not experienced enough in .Net

I'm sure you're great at what you do, in whatever platform you're experienced in. But .Net WebForms isn't your forte. This is one of those times when you should back off and let someone else handle it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top