在MVC4 Razor中组合AppPath [英] Combining AppPath in MVC4 Razor
本文介绍了在MVC4 Razor中组合AppPath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开始使用MVC4 Razor。我期待看到相当于
I am getting started with MVC4 Razor. I am looking to see the equivalent of
<img src="<%=strAppVirtualPath %>/images/logo.jpg" alt="[Logo]" />
。
这应该有哪些变体?但它如何区分+那里?
in MVC.
Should some variant of this work? But how does it discriminate the + there?
<img src="@HttpRuntime.AppDomainAppVirtualPath+images/logo.jpg" alt="[Logo]" />
推荐答案
我自己想出了解决方案。
I figured out the solution myself.
@{
var strLogoPath = HttpRuntime.AppDomainAppVirtualPath;
strLogoPath = string.Format("{0}images/logo.jpg", strLogoPath);
}
<img src="@strLogoPath" alt="[Logo]" />
Marcus,
我唯一担心的是这个人是共享头多页之间。
Marcus,
My only concern is this guy is the shared header between multiple pages.
这篇关于在MVC4 Razor中组合AppPath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文