Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/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 带有ISS的Server.MapPath_Asp.net Mvc_Server.mappath - Fatal编程技术网

Asp.net mvc 带有ISS的Server.MapPath

Asp.net mvc 带有ISS的Server.MapPath,asp.net-mvc,server.mappath,Asp.net Mvc,Server.mappath,Server.MapPath未显示我的IIS 7文件。以下是我的简单代码: @{ Layout = null; } @{ string imgPath = Server.MapPath("~/Views/Home/anim.jpg"); } <img src="@imgPath" /> @{ 布局=空; } @{ 字符串imgPath=Server.MapPath(“~/Views/Home/anim.jpg”); } 不允许直接访问~/Views/文件夹。您可以将

Server.MapPath未显示我的IIS 7文件。以下是我的简单代码:

@{
    Layout = null;
}
@{
    string imgPath = Server.MapPath("~/Views/Home/anim.jpg");
}
<img src="@imgPath" />
@{
布局=空;
}
@{
字符串imgPath=Server.MapPath(“~/Views/Home/anim.jpg”);
}

不允许直接访问~/Views/文件夹。您可以将静态文件放在~/Content/文件夹下,它应该可以工作

我找到了一条讨论这一点的好线索:

我认为将静态文件放在另一个专用于静态文件的文件夹中是一个更好的解决方案。但是,如果要将静态文件存储在Views文件夹中,可以通过修改web.config文件来实现


在您的视图中,您不需要使用Server.MapPath(…)。您只需在视图中使用“~/Content/Images/whatever.jpg”引用您的文件,它就可以工作了。当需要磁盘上文件的实际物理路径时,只能在服务器代码中使用server.MapPath

国际空间站?或者你的意思是IIS?很抱歉,我当时真的很累,睡不着觉。但你还没有把它修好……你是一个摇滚明星jimbo,你还是做不了什么有用的聪明人