I have a simple but script and css fashioned ASP.NET MVC Application, within the VS2008 Development server everything goes well, but when I bring it to IIS7 I experiment some ugly script and images issues.. Scripts are not found by relative paths (this expecially in the default routed page) and images too.
我有一个简单,但脚本和CSS塑造ASP.NET MVC应用程序,在VS2008开发服务器内的一切顺利,但是当我把它给我的IIS7尝试一些丑陋的脚本和图像的问题..脚本不被相对路径发现(这特别是在默认路由页面中)和图像。
After some research and googlin' I found many examples and provided solutions, but anything really solves the problem, Someone says one solution soude be using the Url.Content method but I hate to use it because I lost all the javascript intellisense feature in VS2008..
经过一些研究和googlin'我找到了很多例子并提供了解决方案,但是任何事情都解决了这个问题,有人说一个解决方案是使用Url.Content方法,但我讨厌使用它,因为我丢失了VS2008中的所有javascript intellisense功能。 。
I found too this issue maybe different if the mvc project is shipped in a root web site or in a web application.. I know in a root web site it could works because referencing relative paths like
我发现如果mvc项目在根网站或Web应用程序中提供,这个问题可能会有所不同。我知道在根网站上它可以工作,因为引用相对路径如
<script src="../../Scripts/myScript.js" type="text/javascript" />
in a web application folder is resolved without the root. Anybody has some suggestion or someting else? I Intend after to start something to build a sort of configuration "guide".. Thaks in advance
在没有root的情况下解析Web应用程序文件夹。有人有什么建议或其他吗?我打算开始建立一种配置“指南”之类的东西..提前完成
1 个解决方案
#1
1
It may have been me that suggested using Url.Content. If so, I neglected the other half of what I do -- wrapping a relative path in an if (false) block to retain intellisense. Below is a (full) example of how I handle javascript.
可能是我建议使用Url.Content。如果是这样,我忽略了我所做的另一半 - 在if(false)块中包含相对路径以保留intellisense。下面是我如何处理javascript的(完整)示例。
<% if (false) { %>
<script type="text/javascript"
src="../../Scripts/jquery-1.3.1.min.js">
</script>
<% } %>
<script type="text/javascript"
src='<% Url.Content( "~/Scripts/jquery-1.3.1.min.js" ) %>'>
</script>
#1
1
It may have been me that suggested using Url.Content. If so, I neglected the other half of what I do -- wrapping a relative path in an if (false) block to retain intellisense. Below is a (full) example of how I handle javascript.
可能是我建议使用Url.Content。如果是这样,我忽略了我所做的另一半 - 在if(false)块中包含相对路径以保留intellisense。下面是我如何处理javascript的(完整)示例。
<% if (false) { %>
<script type="text/javascript"
src="../../Scripts/jquery-1.3.1.min.js">
</script>
<% } %>
<script type="text/javascript"
src='<% Url.Content( "~/Scripts/jquery-1.3.1.min.js" ) %>'>
</script>