简体   繁体   English

部署时的asp.net路径问题

[英]asp.net path problem when deploying

We have moved a lot of images and javascript file that was inside class to external Javascript file. 我们已经将许多类内部的图像和javascript文件移到了外部Javascript文件中。 In development (Debug inside Visual Studio), everything look nice, all images show, all javascript works and all CSS display perfectly. 在开发中(在Visual Studio中调试),一切看起来都不错,所有图像都可以显示,所有javascript作品以及所有CSS都可以完美显示。 When we do a package and install with IIS ina virtual directory everything that is pointed by the JavaScript doesn't work. 当我们打包并在虚拟目录中使用IIS安装时,JavaScript指向的所有内容均不起作用。

Question : Since we cannot use the tilde (~) in javascript or in CSS what is the way to display those resources? 问题:由于我们无法在javascript或CSS中使用波浪号(〜),显示这些资源的方式是什么?

Edit 1 编辑1

The problem is the website is installed with a Virtual Directory and if we have in the JavaScript file a popup that has a hardcoded path in the JavaScript the code try to display : " http://localhost/NameSpace/Directory/File.html " instead of " http://localhost/VIRTUALDIRECTORY/NameSpace/Directory/File.html ". 问题是网站安装了虚拟目录 ,如果我们在JavaScript文件中有一个弹出窗口,该弹出窗口在JavaScript中具有硬编码路径,则代码会尝试显示:“ http://localhost/NameSpace/Directory/File.html ”而不是“ http://localhost/VIRTUALDIRECTORY/NameSpace/Directory/File.html ”。 Is there a configuration with IIS or inside the code I need to add something like a parameter to pass the path everytime? 是否使用IIS进行配置,或者在代码内部是否需要添加诸如参数之类的参数以每次均通过路径?

In the javascript in dev it work to have something like : 在dev中的javascript中,它的工作原理如下:

var popWindowPath = '/ProgressFile/Simple/ProgressSlow.htm';

Images for css are, I believe, displayed relative to the css file so that shouldn't be an issue (use relative rather than absolute links). 我认为,css的图像是相对于css文件显示的,因此这不是问题(使用相对链接而不是绝对链接)。

For the js, either have the ability to pass a base link in as an argument or make .js files parsed as .net pages and include code on those pages. 对于js,可以将基本链接作为参数传递,也可以将.js文件解析为.net页面,并在这些页面上包含代码。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM