简体   繁体   English

在 Visual Studio 上通过 IIS Express 运行时可以加载图像,但通过 IIS 运行时无法加载

[英]Image can load when running by IIS Express on Visual studio, but can't load when running by IIS

Create Web Application project in C:\\WebApplication1\\WebApplication1 as below.C:\\WebApplication1\\WebApplication1创建 Web 应用程序项目,如下所示。
在此处输入图片说明 在此处输入图片说明

The file Test/index.aspx文件Test/index.aspx

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <h1>index page</h1>
            <img src="../images/myimage1.png" />
        </div>
    </form>
</body>
</html>

Image can load when running by IIS Express on Visual studio as below.在 Visual Studio 上通过 IIS Express 运行时可以加载图像,如下所示。
在此处输入图片说明


Add Application under Default Web Site on IIS and set Default Document to Test/index.aspx as below. 在 IIS 上的默认网站下添加应用程序,并将默认文档设置为Test/index.aspx ,如下所示。
在此处输入图片说明 在此处输入图片说明 Image can't load when running by IIS. 由 IIS 运行时无法加载图像。
在此处输入图片说明

However, I can open the image by http://localhost/WebApplication1/images/myimage1.png as below. 但是,我可以通过http://localhost/WebApplication1/images/myimage1.png打开图像,如下所示。 在此处输入图片说明

Could you help to suggest me, please? 你能帮我推荐一下吗?

try to use below code:尝试使用以下代码:

<div>
         <h1>index page</h1>
        <img src="./images/myimage1.png" />
    </div>

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio 找不到 IIS Express - Visual Studio can't find IIS Express System.NullReferenceException for .NET 服务在 Windows Server IIS 上运行,但在 Visual Studio IIS Express 中运行时在本地工作 - System.NullReferenceException for .NET service running on windows server IIS but works locally when running in Visual Studio IIS Express 在 Visual Studio 中运行 IIS-Express 时出错 - Error running IIS-Express in Visual Studio 在开发服务器上运行但不在IIS上运行时,COM对象会加载到MVC项目中吗? - COM objects load in MVC project when running on development server but NOT on IIS? 从 Visual Studio 2019 运行时在 IIS Express 上获取 NullReferenceException - Getting NullReferenceException on IIS Express while running from Visual Studio 2019 Visual Studio的IIS Express:无法加载文件或程序集 - Visual Studio's IIS Express: Could not load file or assembly 使用 Visual Studio 运行时查找和替换有效,但在运行 IIS 时出现空异常错误 - Find and Replace works when running with visual studio but when running off of IIS i get null exception error 在IIS下运行时无法连接到Elasticsearch(不尊重访问密钥和机密) - Can't connect to Elasticsearch (access key & secret not being respected) when running under IIS 从 iPad 连接到 Visual Studio (IIS Express) 时出现登录问题 - Login issue when connecting to Visual Studio (IIS Express) from iPad 从Jenkins运行IIS Express时,MSSQLLocalDB登录失败 - Login Failed for MSSQLLocalDB when running IIS Express from Jenkins
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM