[英]Visual studio - Use sub folder as root when viewing in browser (iis)
I am using Visual Studio Express 2013 for Web and I have a folder structure like this. 我正在使用Visual Studio Express 2013 for Web,我有一个像这样的文件夹结构。
domainname.com/src
domainname.com/src/templates
domainname.com/src/templates/default.aspx
domainname.com/dist
domainname.com/dist/default.aspx
There are other folders (images/sass etc.) under my src directory and I'm using grunt to copy/minify them all to the dist folder when I build. 我的src目录下还有其他文件夹(images / sass等),当我构建时,我正在使用grunt将它们全部复制/缩小到dist文件夹。 The idea is that when my colleagues start doing the .net stuff they will copy all their stuff to /dist during build too.
我的想法是,当我的同事开始使用.net时,他们会在构建期间将所有内容复制到/ dist。 So compiled stuff will end up in /dist/bin
所以编译后的东西最终会出现在/ dist / bin中
I'm doing this so I can keep all my original un-minified source files and assets totally separate from my files for distribution. 我这样做是因为我可以将所有原始的未缩小的源文件和资源与我的文件完全分开。 This seems like a sensible thing to do.
这似乎是一件明智的事情。
The problem is that if I use Visual Studio (instead of Sublime) then I File > Open Web Site from the root directory. 问题是,如果我使用Visual Studio(而不是Sublime),那么我从根目录下文件>打开网站。 When I then "view in browser" it uses the following URL.
当我然后“在浏览器中查看”时,它使用以下URL。
http://localhost:58218/dist/Default.aspx
...and none of my links to images/css/js work any more because all the links are relative. ...而且我对images / css / js的链接都不再起作用,因为所有的链接都是相对的。
What I want to do is be able to open the whole folder in VS2013, including the root folder and src folder etc so I can edit the source code, then once it's built/grunted I want to make IIS run the /dist website as if it was the root. 我想要做的是能够在VS2013中打开整个文件夹,包括根文件夹和src文件夹等,所以我可以编辑源代码,然后一旦它被构建/哼唱我想让IIS运行/ dist网站就好像它是根。
If I open the /dist file as a folder and run from there then it all works, but obviously I don't have access to the parent folder and src folder to work on the site. 如果我打开/ dist文件作为文件夹并从那里运行然后一切正常,但显然我没有访问父文件夹和src文件夹来在网站上工作。
I hope I explained that well enough. 我希望我解释得那么好。
I would highly suggest you check out the url rewriting solution that Seb came up with in this answer . 我强烈建议你查看Seb在这个答案中提出的网址重写解决方案。 I have the same setup as you and it works beautifully.
我有与你相同的设置,它工作得很漂亮。
I would not use the "automation" stuff that asp.net does for you because that work is done in production. 我不会使用asp.net为您做的“自动化”工作,因为这项工作是在生产中完成的。 This sort of work is very ideal for being done at build time.
这种工作非常适合在构建时完成。 Less work that you do in production means that there is less to break in production and cause an outage.
您在生产中所做的工作量减少意味着生产中断的可能性较小并导致停机。
You probably want two websites here -- one for dev work that VS express knows (could be the default IIS Express site), a second one pointed at the webroot that you setup outside of the project. 您可能需要两个网站 - 一个用于VS express知道的开发工作(可能是默认的IIS Express站点),第二个用于指向您在项目外部设置的webroot。
Also, if this is a .NET site, note that ASP.NET 4 automates a lot of the stuff grunt does in terms of combining and minifying the javascripts and CSS so you might be able to skip that step. 此外,如果这是一个.NET站点,请注意ASP.NET 4自动化了grunt在组合和缩小javascripts和CSS方面所做的很多工作,因此您可以跳过该步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.