Web 应用程序的 IIS 上的根引用不起作用,ASP.NET 4.0
我的 IIS 有奇怪的问题。
在我的网络服务器上我有一个网络应用程序。 基本上我将文件夹转换为应用程序,我认为我做得很好。我还从下面的链接咨询了 Microsoft 的指示,以确保我没有错过任何内容:
http://msdn.microsoft.com/en-us/library/ha2y9493.aspx
无论如何,现在,在我的应用程序中,
这不起作用:
<img src="/images/7eleven.png" />
但是,这有效:
<img runat="server" src="~/images/7eleven.png" />
我的物理路径如下所示:
\\server\apps\myapplication\images
myapplication 是 .NET 4.0 WEB 应用程序,我希望它是应用程序根。
但是,据我现在所见,当使用 runat="server" 时,它仅适用于服务器控件。有补救办法吗?
谢谢。
I have weird problem with my IIS.
On my webserver I have an web application.
Basically I converted folder into application and I assume that I did it all alright. I also consulted Microsoft directions from link below just to make sure that I didn't miss anything:
http://msdn.microsoft.com/en-us/library/ha2y9493.aspx
Anyway, now, in my application,
This doesn't work:
<img src="/images/7eleven.png" />
but, this works:
<img runat="server" src="~/images/7eleven.png" />
My physical path goes like this:
\\server\apps\myapplication\images
myapplication is .NET 4.0 WEB APPLICATION and I expect it to be an application root.
But, as far as I can see now, it is root only for server controls when runat="server" is used. Is there remedy for this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您网站的根目录是否位于 IIS
\\server\apps\myapplication\
中?据我从你的问题中可以看出,它是应用程序的根目录,但你没有说它是网站的根目录。客户端不知道应用程序边界,因此除非您的站点根目录中有
\\server\apps\myapplication\
,否则第一个示例标记中的绝对 URL 将不起作用。补救措施是使用服务器端控件或代码块将正确的路径注入到
img src
中,如第二个示例所示。Is the root of your site in IIS
\\server\apps\myapplication\
? As far as I can tell from your question, it is the root of the application, but you didn't say it is the root of the site.Clients don't know about application boundaries, so unless you have
\\server\apps\myapplication\
at the root of your site, the absolute URL in your first example markup will not work.The remedy is to use a server-side control or code block to inject the proper path into the
img src
, as in your second example.我认为最好使用
Server.MapPath("~")
这将进一步解释它 ASP.NET Web 项目路径
I think its better to use
Server.MapPath("~")
This will explain it further ASP.NET Web Project Paths