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

The Archive Base Latest Questions

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

I want to know two things about ASP.NET MVC2 that I’ve researched from Google

  • 0

I want to know two things about ASP.NET MVC2 that I’ve researched from Google but still confusing. Hope I can find clear and clean answer here.

First, how to upload a file to server with custom file path. (Eg. to /Content/Files)

Second, how to download that file, since the url has applied URL Rounting, how to map to them?

Thanks for your answers!

  • 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-18T06:01:17+00:00Added an answer on May 18, 2026 at 6:01 am

    To upload, you’ll use something like this.

    <form action="/MyController/SaveDocuments/" method="post" enctype="multipart/form-data">
    
            <label for="file1">Document 1</label>
            <input type="file" id="file1" name="file1" />
    
    </form>
    

    And here’s the code on the controller to save the file:

         public Document[] SaveDocuments(HttpRequestBase iHttpRequest, Instruction instruction)
        {
            List<Document> documents = new List<Document>();
    
            foreach (string inputTagName in iHttpRequest.Files)
            {
                HttpPostedFile file = iHttpRequest.Files[inputTagName];
                if (file.ContentLength > 0)
                {
                    if (Path.GetExtension(file.FileName).Length == 0)
                    {
                        throw new ValidationException(string.Format("File '{0}' has no extension (e.g. .doc .pdf)", file.FileName));
                    }
                    string filePath = documentService.BuildDocumentPath(instruction.InstructionId, file.FileName);
                    file.SaveAs(filePath);
    
                    documents.Add(new Document
                    {
                        Filename = Path.GetFileName(file.FileName),
                        Path = filePath
                    });
                }
            }
    
            return documents.ToArray();
        }
    

    As for downloading, say you have the directory “~/Content/Files”…

    You just have to exclude them in your route.

    routes.IgnoreRoute("Content/{*pathInfo}");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know some basic, practical, things about Services, that are not explicitly
Let's say I know two points that make up a line. I want to
I want to know how to create a label that contains two icons, one
I just want to know if is possible to calculate the diference between two
Hi i want to know how to find the distance between two markers in
I just want to know what is the difference between these two messaging constants.
i'm amol kadam,I want to know how to split string in two part.My string
Using sqlite3, I have two tables: products, orders. I want to know how many
please help me. I want know about what types of flags to run an
I have a pretty big web application that I created last year using ASP.NET

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.