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

  • Home
  • SEARCH
  • 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 8093591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:32:03+00:00 2026-06-05T20:32:03+00:00

It is easy to restrict access to aspx pages, just use role-checking logic in

  • 0

It is easy to restrict access to aspx pages, just use role-checking logic in the code-behind. But resource files like a photo does not have a code behind to put role-checking logic, so how to restrict access?

  • 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-06-05T20:32:04+00:00Added an answer on June 5, 2026 at 8:32 pm

    First, you will need to set up IIS. If you have IIS7+, it’s a snap. Change your app pool from Classic to Integrated Pipeline. This allows managed modules and handlers to be applied to your static resource files. If you are using IIS6, see this article.

    Second, you may need to ensure this setting in your web.config (for IIS7):

      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
    

    Things like FormsAuth should now work the same as they would for ASPX, etc., meaning you can restrict paths to authorized users only by using web.config (for example).

    Update

    In response to Aperture’s comment below:

    Outside of using RoleProviders, ASP.NET can figure out the roles for a principal either by reading groups a user belongs to when using Windows auth, or manually changing the roles by replacing the current IPrincipal in your application, preferably during AuthenticateRequest.

    Global.asax.cs

    public void Application_AuthenticateRequest(object sender, EventArgs e)
    {
        var application = sender as HttpApplication;
        var context = application.Context;
    
        if (!context.User.Identity.IsAuthenticated) return; // if the user hasn't been authenticated by another module such as FormsAuth, don't do anything further
    
        string[] roleNames = FindRolesForUser(context.User.Identity.Name); // this method you will create to figure out what roles the specified user has
        context.User = new GenericPrincipal(new GenericIdentity(context.User.Identity.Name), roleNames); // updates the current principal. 
    }
    

    Now, as far as checking the roles we’ve specified above, there are a number of ways. You could create a custom HttpModule that looks for paths that end in JPG, GIF, JS, etc. and then simply check context.User.IsInRole. You could also simply use location and authorization in your web.config:

       <location path="images">
          <system.web>
             <authorization>
                <allow users="?"/> <!-- or perhaps <allow roles="Admins" /> it's up to you -->
             </authorization>
          </system.web>
       </location>
    

    The bottom line is, you can’t execute any managed code during the request to static resources until you either configure Integrated Pipeline, or map static resources to the ASP.NET ISAPI module. So, my answer is appropriate.

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

Sidebar

Related Questions

An easy problem, but for some reason I just can't figure this out today.
Sounds easy, but I've got a bug and I'm not sure what's causing it?
any easy to use utility/tool/profiler/benchmark that able to test what is the maximum users
Using top it's easy to identify processes that are hogging memory and cpu, but
Possible Duplicate: before_filter :require_owner I am trying to restrict access to certain actions using
I'm sure there's an easy answer to this, but for the moment it escapes
I'm using the Toolkit's Datepicker as above but I'd like to restrict it to
Easy question, but couldn't find it in the doc. How do I slice a
Easy one here I think, can you confirm that each code page is implemented
Generating a UIWebView with on-board resources is easy enough with the following code. NSString

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.