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

Ask A Question

Stats

  • Questions 493k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You could set the .height() and .width() using the start… May 16, 2026 at 10:54 am
  • Editorial Team
    Editorial Team added an answer I assume this answers your question? http://search-lucene.com/m/A6gcf1wWZdv May 16, 2026 at 10:54 am
  • Editorial Team
    Editorial Team added an answer 3.5 AND 4 support windows app fabric. May 16, 2026 at 10:54 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

We have a suite of interlinked .Net 3.5 applications. Some are web sites, some
Is there a way to add a config file for WP7 apps like there
I am responsible for several ASP.NET web apps running on a local Intranet server.
I have CruiseControl.NET configured to monitor 10+ .NET projects. All of these projects (web
I would like to design webapps (eg. games) that have low latency. I presume
We have an app template we've created in asp.net 2.0 that we use for
I have installed WAMP and enable some extension. After that i have installed eclipse
Not sure how to frame this one, so here goes... I have a need
We as a group develop Javascript/JSP web application, and the problem is we are
My employer currently has most of its access to the database through C# sqlDataAdapters

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.