简体   繁体   English

Visual Studio - 在浏览器中查看时以root用户身份使用子文件夹(iis)

[英]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.

相关问题 如何使用Response.Redirect从子文件夹重定向到ASP.NET中的根目录,防止用户查看目录列表 - How to use Response.Redirect from sub folder to root in ASP.NET, Prevent user from viewing directory listing 从Visual Studio中在浏览器中查看Web服务涉及什么过程? - What is the process involved in viewing a webservice in a browser from within visual studio? 当我通过 Visual Studio 中的 IIS Express 在浏览器中打开 web 应用程序时,为什么会给我这个错误? - Why give me this error when I open web app in browser through IIS Express in visual studio? 是否可以访问IIS 7.0的子目录中的根App_Code文件夹和App_Code文件夹? - Is there a way to access both a root App_Code folder and an App_Code folder in a sub directory in IIS 7.0? 在网站的根目录时,不会附加Visual Studio调试器 - The Visual Studio debugger is not attaching when at the root of a website IIS中的Visual Studio“ Microsoft shared \\ DevServer \\ 10.0”文件夹是否等效? - Is there an equivalence for visual studio “microsoft shared\DevServer\10.0” folder in IIS? 在没有 IIS 的情况下,浏览器中的视图选项如何在 Visual Studio 中工作? - How does the view in browser option work in Visual Studio without IIS? 在Visual Studio 2013中创建新项目时,出现错误,因为它们会自动尝试使用IIS express - When creating a new project in Visual studio 2013 I get an error because they are automatically trying to use IIS express 使用IIS6,如何将文件放置在子文件夹中,但就像在根目录中一样提供文件? - Using IIS6, how can I place files in a sub-folder but have them served as if they were in the root? 更改iis 7的Inet根文件夹 - Change Inet root folder for iis 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM