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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:17:18+00:00 2026-05-13T13:17:18+00:00

I want to protect the files in a specific directory so that people cannot

  • 0

I want to protect the files in a specific directory so that people cannot link to them – but I still need my program to be capable of rendering them, so password protecting the actual folder won’t work. Is there any way to facilitate this in ASP.NET MVC? Obviously it’s more about ASP.NET, not MVC – but I can’t make use of things like Session State and Postback and such…

  • 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-13T13:17:19+00:00Added an answer on May 13, 2026 at 1:17 pm

    You could put that directory outside of the web app’s root directory (so that it can’t be accessed using some copied URL) or into a directory where you deny any read access using a web.config file.

    Then access the files through an action which requires the current user to be authorized, e.g:

    public class FileController : Controller
    {
      [Authorize]
      public ActionResult Get(string file)
      {
        return new File(Path.Combine(_rootPath, file);
      }
    }
    

    Then you can access the files through an action URL, e.g. http://server/app/File/Get/test.txt.

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

Sidebar

Related Questions

I want to protect a directory and the php files in it, from direct
I want to create a project that uses source files already on my filesystem,
I want to load some .css files to my Django project but I don't
I have some elisp files in a project that I want to byte compile
I have a project that requires some configuration files. I want to keep the
edit I do not want to redirect pages, specific files etc. I would like
I want to write an OSX (Snow Leopard) app that receives notifications when files
I want to create an application that will automate a very specific build process
I'm writing a PHP function that will delete all the files in the directory
I want to try CMake to manage a new C++ project. However, some files

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.