You will need to specify the path to the action, which will receive the file name, resolve the full path and then transfer the file to disk from the server to the client. Fortunately, clients on the Internet cannot read files directly from your server's file system (unless ... you assume that @Model.CertificatePath is the file path on the remote user's machine?).
public ActionResult Download(string fileName) { string path = Path.Combine(@"C:\path\to\files", fileName); return File(path, "application/pdf"); }
Update
If @Model.CertificatePath is the location on the actual client machine, try:
<a href="file://@Model.CertificatePath" target="_blank" class="button3">Open</a>
Please note that some browsers may have security settings that prevent you from opening local files.
Hackedbychinese
source share