Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.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 3 MVC3如何指定图像的路径_Asp.net Mvc 3 - Fatal编程技术网

Asp.net mvc 3 MVC3如何指定图像的路径

Asp.net mvc 3 MVC3如何指定图像的路径,asp.net-mvc-3,Asp.net Mvc 3,图像位于:/Content/panoramas/panoramas/UCCParc.tif下 我访问图像的方式如下: <img src="@Url.Content("~/Content/panoramic/panoramas/" + @imgName + "")"/> 但是,当我尝试加载页面localhost/pano(其中pano是一个控制器)时,找不到图像。这是访问MVC3中文件的正确方法吗?将文件夹层次结构指定为图像的路径是正确的,还是应该以某种方式在路径周围包装一个控制

图像位于:/Content/panoramas/panoramas/UCCParc.tif下

我访问图像的方式如下:

<img src="@Url.Content("~/Content/panoramic/panoramas/" + @imgName + "")"/>


但是,当我尝试加载页面localhost/pano(其中pano是一个控制器)时,找不到图像。这是访问MVC3中文件的正确方法吗?将文件夹层次结构指定为图像的路径是正确的,还是应该以某种方式在路径周围包装一个控制器

您的代码似乎很好,但找到问题的最佳方法是使用“Inspect Element”或其他工具(Firefox中的bug)查找代码生成的正确URL。(右键单击images space并选择“Inspect Element”,查看图像路径是否正确)。

Url.Content()生成的路径是什么?/Content/panoramas/img1.jpgI这样做的。url是可以的,但我认为当浏览器发送请求从/Content/panoramas/img1.jpg获取图像时,mvc3会寻找一个名为Content/的控制器,等等。。。