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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:35:54+00:00 2026-05-24T20:35:54+00:00

I have an upload function in an MVC 3 project which store the files

  • 0

I have an upload function in an MVC 3 project which store the files in a database. I am trying to write code that will list all the files in the database with a link to download each one, but I have not having much success. Here is the controller code:

        public ActionResult Download(int id)
    {
        var db = GetDataContext();
        var file = db.UserFiles.First(f => f.ID == id);
        return File(file.Data.ToArray(), "application/octet-stream", file.Name);
    }

    public ActionResult Index()
    {
        var db = GetDataContext();
        var files = db.UserFiles.Select(f => new FileViewModel { ID = f.ID, Name = f.Name });
        return View(files);
    }

I have created a view from the ActionResult Index and the code in the view is:

@Html.ActionLink("Lesson", "Download", "Upload", new { id = 1 })

I have also created a class file called FileViewModel, which serves to prevent the data being retrieved from the database when the files are listed:

    public class FileViewModel
{
    public int ID { get; set; }
    public string Name { get; set; }
}

And in the download View where I will list the files, I have:

@model IEnumerable<DFPProductions_Default.Models.FileViewModel>

The error I’m getting when I click on the link is:
The parameters dictionary contains a null entry for parameter ‘id’ of non-nullable type ‘System.Int32’ for method ‘System.Web.Mvc.ActionResult Download(Int32)’ in ‘DFPProductions_Default.Controllers.UploadController’.

Please help me discover what I’ve done wrong.
Thanks,
Amy

  • 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-24T20:35:55+00:00Added an answer on May 24, 2026 at 8:35 pm

    The problem seems to be you are not sending any Id to the Controller.
    Try calling you action link:
    @Html.ActionLink("Lesson", "Download", "Upload", new { id = 1 }, null)

    Also, for future reference, you should keep the controller to a minimum, no interactions with the database.

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

Sidebar

Related Questions

I have a file upload function in my asp.net mvc application that allows users
I have an upload function in my system that stores the files on the
I have a data-upload function that load some data into several tables and processes
I have an upload script that write a index.html file, I modified it to
On my asp.net 4.0 site I have a upload function which allow a user
I have time consuming function upload /* around 10 sec */. I am trying
I'm trying to make an App-wide media-upload which should have the possibility of being
I have users upload files into a fake directory structure using a database. I
I have download the code for OpenFileDialog (File Upload function) from Silverlight tutorials website.
what I'm trying to do is have a upload button to upload files to

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.