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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:01:02+00:00 2026-06-18T02:01:02+00:00

User can download price information PDFs located in a folder PriceInformations with subfolders specifying

  • 0

User can download price information PDFs located in a folder PriceInformations with subfolders specifying the document type, e.g.:

/PriceInformations/Clothes/Shoes.pdf
/PriceInformations/Clothes/Shirts.pdf
/PriceInformations/Toys/Games.pdf
/PriceInformations/Toys/Balls.pdf

Consider following action in Controller Document to download those PDFs:

// Filepath must be like 'Clothes\Shoes.pdf'
public ActionResult DownloadPDF(string filepath)
{
    string fullPath = Path.Combine(MyApplicationPath, filepath);

    FileStream fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read);

    return base.File(fileStream, "application/pdf");
}

To get a PDF document, my client wants URLs to be like:

/PriceInformations/Clothes/Shoes.pdf

I could easily create an overload function for this case:

public ActionResult DownloadPDF(string folder, string filename)
{
    return this.DownloadPDF(Path.Combine(folder, filename);
}

And map it like

routes.MapRoute(
    "DownloadPriceInformations",
    "DownloadPriceInformations/{folder}/{filename}",
    new
    {
        controller = "Document",
        action = "DownloadPDF"
    });

But I’m curious if it would be possible to work without an overload function and to map this case in RegisterRoutes in Global.asax, so to be able to create one single parameter out of of multiple parameters:

routes.MapRoute(
    "DownloadPriceInformations",
    "DownloadPriceInformations/{folder}/{filename}",
    new
    {
        controller = "Document",
        action = "DownloadPDF",
        // How to procede here to have a parameter like 'folder\filename'
        filepath = "{folder}\\{filename}"
    });

Question became a bit longer but I wanted to make sure, you get my desired result.

  • 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-18T02:01:03+00:00Added an answer on June 18, 2026 at 2:01 am

    Sorry, this is not supported in ASP.NET routing. If you want multiple parameters in the route definition you’ll have to add some code to the controller action to combine the folder and path name.

    An alternative is to use a catch-all route:

    routes.MapRoute(
        "DownloadPriceInformations",
        "DownloadPriceInformations/{*folderAndFile}",
        new
        {
            controller = "Document",
            action = "DownloadPDF"
        });
    

    And the special {*folderAndFile} parameter will contain everything after the initial static text, including all the “/” characters (if any). You can then take in that parameter in your action method and it’ll be a path like “clothes/shirts.pdf”.

    I should also note that from a security perspective you need to be absolutely certain that only allowed paths will be processed. If I pass in /web.config as the parameter, you must make sure that I can’t download all your passwords and connection strings that are stored in your web.config file.

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

Sidebar

Related Questions

In my struts application, a user can download a file from the server. I
I'm making an Android app where the user can download files from a FTP-server.
I would like to in my application user can download content on http, but
I am developing a webpage in that the user can download their Resume for
Say I have a C++ program that any user can download on their machine.
I'm building a site where the user can download ePub files and Adobe Digital
I'm developing a quick rapidshare-like site where the user can download files. First, I
I have images on my website where the user can download selected images. When
in my application,user can download and play videos from different video sites like bofunk.com,dailymotion.com,youtube.com,metacafe.com,stupid
I've developed an application in which user can download .mp3 files from server. And

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.