Jonathan Padilla
Jonathan Padilla

Reputation: 67

View returns null to controller action

I'm using razor view to display the info and the info display perfectly but when I press the action link to download the file the action comes null from the view.

View:

@model Innovation_Internship.Models.Applicant

@Html.ActionLink("Download", "Download", "Admin", new { filename = Model.Resume }) 

Controller:

 public ActionResult Download(string filename) <-- comes null
    {
        try
        {

        }
        catch (Exception)
        {
            //download failed 
            //handle exception
            throw;
        }
    }

Upvotes: 0

Views: 45

Answers (1)

Ozoid
Ozoid

Reputation: 149

Model.Resume seems to be an object rather than as string. Maybe the object or refrence is null. - maybe use .ToString()

Also add null to the end or you may call the wrong version of the function

@Html.ActionLink("Text","Action","Controller", new { item.ID }, null)

There is also another SO post related: HTML.ActionLink method

Upvotes: 1

Related Questions