Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc “文件://”指向“href”下载链接MVC.NET的路径_Asp.net Mvc_Hyperlink_Filepath - Fatal编程技术网

Asp.net mvc “文件://”指向“href”下载链接MVC.NET的路径

Asp.net mvc “文件://”指向“href”下载链接MVC.NET的路径,asp.net-mvc,hyperlink,filepath,Asp.net Mvc,Hyperlink,Filepath,我有一个位于本地的文件:C:\foo\test.txt,可作为字符串访问。 我的MVC应用程序根目录是:C:\Projects\Websiteroot 我需要的是生成一个链接,可以下载该文件 但请记住: 我无法在应用程序IIS中添加虚拟文件夹。因为明天该文件夹将不存在,我必须访问其他文件夹中的该文件,如:D:\other\folder\test.txt 甚至在这里:\sharedResource\whateverfolder\test.txt 所以我只有这个字符串,我需要把它转换成http链接,

我有一个位于本地的文件:C:\foo\test.txt,可作为字符串访问。 我的MVC应用程序根目录是:C:\Projects\Websiteroot

我需要的是生成一个链接,可以下载该文件

但请记住: 我无法在应用程序IIS中添加虚拟文件夹。因为明天该文件夹将不存在,我必须访问其他文件夹中的该文件,如:D:\other\folder\test.txt 甚至在这里:\sharedResource\whateverfolder\test.txt

所以我只有这个字符串,我需要把它转换成http链接,就像这里的一个: 下载


非常感谢:

您需要发布一些代码供大家查看,否则我们将猜测//返回服务器字符串filePath=getFilePathtestfile上的文件位置,2014年9月12日//返回文件:///path Uri=new System.UrifilePath;///将在Viewas href下载链接中使用的链接-我如何获得它?字符串href=;这是我的控制器的一部分,用来生成下载链接。我将一些参数传递给它。。。关键是它为我生成了一个文件路径。类似于:C:\folder\file.txt或similar