Q:

ASP.NET @Url.Action does not generate link for downloading files

I have a blog type website (guided by the 3DBuzz video tutorial) with a back-end (for administration purpose) and a front-end. In both back-end and front-end the user should be able to download a file.
The Action for both the front-end and the back-end:
public ActionResult Download(string filename)
    {
        var filepath = System.IO.Path.Combine(Server.MapPath("~/Content/Files/"), filename);
        if (!System.IO.File.Exists(filepath))
            return HttpNotFound();

        return File(filepath, MimeMapping.GetMimeMapping(filepath), filename);
    }

The front-end view (the @Url.Action is the same in both the front-end and the back-end):
@foreach (var file in Model.Post.Files)
{
<a class="list-group-item file-download" href='@Url.Action("Download", "Posts", new { filename = file.FileName } )' id="@file.FileName">
        <span class="name">@file.FileName</span>
</a>
 }

I do not have any routes configured for this action.
The thing is that in the back-end the url is generated and I can download the files
<a class="file-link" href="/admin/Posts/Download?filename=putty.exe">putty.exe</a>

But when i want to download from the front-end... no link is generated:
<a class="list-group-item file-download" id="putty.exe">
                    <span class="name">putty.exe</span>
</a>

If I create a route in the routeConfig:
routes.MapRoute("DownloadFile", "downloadFile/{filename}", new { controller = "Posts", action = "Download" }, namespaces);

the generated link is:
<a class="list-group-item file-download" href="/downloadFile/putty.exe" id="putty.exe">
           <span class="name">putty.exe</span>
</a>

but when I click on this link I get a 404 Not Found

A:

Make sure you run your webapplication in integrated mode, and add the following to your global.asax:
routes.RouteExistingFiles = true;

You probably want to exclude the files in the Content folder from your routing by adding the following line to the global.asax:
routes.IgnoreRoute("Content/{*pathInfo}");

