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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:31:54+00:00 2026-06-08T18:31:54+00:00

I have file uploads working great on an ASP MVC3 web site. Currently the

  • 0

I have file uploads working great on an ASP MVC3 web site. Currently the files are saved in a folder on the web site called “Files”. Users can upload any type of file (e.g. myphoto.jpg, mydocument.docx, etc).

When a user uploads a file I store information about the file in a SQL database and who uploaded it etc.

My questions:

  1. How do I intercept a GET request to a file URL (e.g. /Files/myphoto.jpg) to see if the user is allowed to view that file? (based on their rights in the application)? I don’t like the idea of writing a route constraint to check the database before allowing access.
  2. Ideally I’d like to store the files in a different location than the web site file location, but somewhere where the website can determine the file and it’s location from the request, yet serve it up as if it was at the location requested (correct content-type headers etc).
  • 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-08T18:31:55+00:00Added an answer on June 8, 2026 at 6:31 pm

    You can add a controller to server the files.

    public class FileController : Controller
    {
    
        private IFileStore _fileStore;
    
        public FileController(IFileStrore fileStore)
        {
            this._fileStore = fileStore; 
        }
    
        public ActionResult Index(string fileName)
        {
            // Do a database look up if the user has permission
            if (_fileStore.HasPermission(fileName, User))
            {
                // Flush the file content if the user has permission
                var myfile = _fileStore.GetFile(fileName);
                Response.ClearContent();
                Response.AddHeader("Content-Disposition", "attachment; filename=" + myfile.FileName);
                Response.AddHeader("Content-Length", myfile.Length.ToString());
    
                Response.ContentType = myfile.Extension.ToLower();
                Response.WriteFile(myfile.FullName, false);
                Response.Flush();
                Response.Close();
            }
            else
            {
                // Return a Access Denied page
                return View("NoPermission");
            }
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an ASP web page that handles file uploads. Only certain
I have a Rails application that accepts file uploads of CSV files. When developing
I have a website which allows secure (ssl) file uploads and download. The site
I have an ASP.NET MVC page with multiple file uploads. After a failed post,
I have been using a jquery plugin called uploadify for handling file uploads as
I have the Tinybrowser plugin working with TinyMCE for file uploads. Everything is working
I am working on an admin area that will have file uploads on several
I'm working on handling file uploads using express.js and node, and have the basic
I'm working on a project that has file uploads. These files are given a
I am working on an ASP.net project and I have a file upload control.

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.