Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.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 ASP.NET MVC IIS问题_Asp.net Mvc - Fatal编程技术网

Asp.net mvc ASP.NET MVC IIS问题

Asp.net mvc ASP.NET MVC IIS问题,asp.net-mvc,Asp.net Mvc,我在ASP.NET MVC应用程序的.cs文件中有以下代码: HtmlTableCell r2c1 = new HtmlTableCell(); r2.Cells.Add(r2c1); r2c1.ColSpan = 2; r2c1.Style.Add("font", "1px arial"); r2c1.Style.Add("height", "10px"); r2c1.Style.Add("background-image", "url(/Content/Images/pagebgbottom

我在ASP.NET MVC应用程序的.cs文件中有以下代码:

HtmlTableCell r2c1 = new HtmlTableCell();
r2.Cells.Add(r2c1);
r2c1.ColSpan = 2;
r2c1.Style.Add("font", "1px arial");
r2c1.Style.Add("height", "10px");
r2c1.Style.Add("background-image", "url(/Content/Images/pagebgbottomwhite.jpg)");
r2c1.Style.Add("background-repeat", "repeat-x");
这在本地运行正常,但当我使用IIS 5部署我的应用程序时,我看不到这种情况


如何更改URL的格式以便查看它?

首先,您不希望在演示者中包含此类代码


至于URL格式,请尝试
Server.MapPath(“~/Content/Images/pagebgbottomwhite.jpg”)。并确保该文件确实位于它应该位于的位置。

您确实应该使用CSS并定义一个具有这些属性的类。url将与CSS文件在站点中的位置相对:url(../Images/pagebgbottomwhite.jpg)——假设您的CSS文件位于图像的同级目录中。然后将CSS类应用于元素

我也同意Anton的观点,使用MVC时,这些代码不应该出现在控制器/模型中,而应该出现在视图中——在这种情况下,您将不会使用HtmlTableCell。在这种情况下,使用纯CSS,只需在表中创建适当的行

  <tr><td class="bottom-row" colspan="2"></td></tr>


确认已部署此文件(/Content/Images/pagebgbottomwhite.jpg)。它是否设置为不复制或在部署中被丢弃。

根虚拟目录是什么?它将是D:\deploy\并且我在这里得到了/Content/Images/pagebgbottomwhite.jpg。如果我使用的是HttpContext.Current.Server.MapPath(“~/Content/Images/pagebgbottomwhite.jpg”);它不存在;如果不使用iisi进行部署,则无法工作。您可以看到部署文件夹中的文件