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 973959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:21:35+00:00 2026-05-16T03:21:35+00:00

So, I have web apps with web.configs like so: <authorization> <deny users=?/> </authorization> …

  • 0

So, I have web apps with web.configs like so:

<authorization>
  <deny users="?"/>
</authorization>
...
<location path="SomeUnsecuredPage.aspx">
  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>
</location>

In other words, most pages require authentication and authorization, but some don’t.

Then I have an IHttpModule that will be used by all the different applications. All I want to do is check if the current request is “secured” at all. If the page doesn’t require authorization I don’t want my IHttpModule to do anything at all. I am using FormsAuthentication and I assume that FormsAuthentication already has all of this information cached somewhere, doesn’t it? Also, since this check will be running constantly so it has to be very quick.

I am currently subscribing to the HttpApplication.AuthorizeRequest, but surprisingly this event fires even for resources that allow anonymous access.

Any ideas? Thanks for reading!

  • 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-16T03:21:36+00:00Added an answer on May 16, 2026 at 3:21 am

    Create a bootleg IPrincipal and then you have to use that. If the bootleg principal has access then anonymous access is allowed.

    public static class AnonymousAccessCheck
                {
                    public static bool IsAnonymousAccessAllowed(HttpRequest request)
                    {
                        // unfortunately checking if a page allows anonymous access is more complicated than you'd think(I think).
                        // here we have to create a "Fake" IPrincipal that will only ever have access to 
                        // pages that allow anonymous access.  That way if our fake principal has access,
                        // then anonymous access is allowed
    
                        UrlAuthorizationModule urlAuthorizationModule = new UrlAuthorizationModule();
                        return UrlAuthorizationModule.CheckUrlAccessForPrincipal(request.Path, AnonymousPrincipal.Instance, request.RequestType);
                    }
    
                    private class AnonymousPrincipal : IPrincipal
                    {
                        private static AnonymousPrincipal _Instance;
                        public static AnonymousPrincipal Instance
                        {
                            get
                            {
                                if (_Instance == null)
                                    _Instance = new AnonymousPrincipal();
    
                                return _Instance; 
                            }
                        }
    
                        private AnonymousPrincipal()
                        {
                            _Identity = new AnonymousIdentity();
                        }
    
                        private readonly IIdentity _Identity;
    
                        #region IPrincipal Members
    
                        public IIdentity Identity
                        {
                            get { return _Identity; }
                        }
    
                        public bool IsInRole(string role)
                        {
                            return false;
                        }
    
                        #endregion
    
                        private class AnonymousIdentity : IIdentity
                        {
                            #region IIdentity Members
                            public string AuthenticationType
                            {
                                get { return string.Empty; }
                            }
    
                            public bool IsAuthenticated
                            {
                                get { return false; }
                            }
    
                            public string Name
                            {
                                get { return string.Empty; }
                            }
                            #endregion
                        }
                    }
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.