Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 534021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:34:07+00:00 2026-05-13T09:34:07+00:00

I need to secure access to all pages in a .NET webapp – EXCEPT

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:34:07+00:00Added an answer on May 13, 2026 at 9:34 am

    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.

    public class SecurityModule : IHttpModule
    {
        private HttpApplication m_HttpApplication;
    
        public void Init(HttpApplication context)
        {
            m_HttpApplication = context;
            m_HttpApplication.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
        }
    
        public void Dispose()
        {
            // Do Nothing
        }
    
        private void OnPreRequestHandlerExecute(object sender, EventArgs e)
        {
            // Get IP address
            string ipAddress = m_HttpApplication.Context.Request.UserHostAddress;
    
            // Check if the IP address requires login
            bool requiresLogin = ValidateIpAddress(ipAddress);
    
            // Redirect if required
            if (requiresLogin)
                Response.Redirect("~/Login.aspx", true);
            }
    
            private bool ValidateIpAddress(string ipAddress)
            {
                // This method would check that the IP address is from the local
                // network or in the database and return true or false accordingly.
    
                return false;
            }
        }
    

    You’ll also need to modify web.config and add a reference to the module:

    <httpModules>
        <add name="SecurityModule" type="MyApp.SecurityModule, MyApp"/>
    </httpModules>
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: In MS Access you can hold the shift key when opening a database
For redirecting every request on my server to a secure connection I use RewriteCond
I'm using Spring 3.0.3 with Spring Security. So, I have fairly lenient restrictions on
I'm using the default securityConfigType which is set to use annotations. What are my
I was just thinking about the URLs of my current web project. The user
If someone can tell me what I'm doing wrong it'd be great. If not,
I am trying to catch any https traffic to the front of my site
I have a new set up for software development for iOS devices. I am
Let me preface this question by stating that i don't usually condone the practice
Edit, as per these comments: Do you mean "Property" vs "Field"? public String S1;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.