Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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. The idea is that when my colleagues start doing the .net stuff they will copy all their stuff to /dist during build too. So compiled stuff will end up in /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. When I then "view in browser" it uses the following 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.

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.

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.

I hope I explained that well enough.

like image 848
jonhobbs Avatar asked Nov 24 '22 04:11

jonhobbs


1 Answers

I would highly suggest you check out the url rewriting solution that Seb came up with in this answer. 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. 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.

like image 164
Allen Rice Avatar answered May 23 '23 14:05

Allen Rice