How to use www root level web.Config file with "Use Visual Studio Development Center" - visual-studio

I hope I can explain this question sufficiently...
In the past, we have utilized a web.Config file in the wwwroot folder so multiple sites can pick up the same connectionstrings/app settings (it also allows us to have different connectionstrings on different servers, so we could publish the project without having to make changes to its web.config every time).
I'm trying to do that with Visual Studio 2010. I have a Web Project, and under Properties - Web tab, I have "Use Visual Studio Development Server" and a Virtual Path. Since it's not running under IIS, it won't pick up a config file stored in c:\inetpub\wwwroot (makes sense). Is there a way to get it to pick up such a file in this situation?

Related

How to create virtual directory on Local IIS using MSBuild and properties of a project

I have VS2017 project with predefined usage of Local IIS in properties.
I have a Project Url as http://localhost/MyProject.Name there and want to see it on IIS the same way under Default Web Site (localhost:80, nothing special)
Default Web Site
|-----> other files
|-----> web.config
|-----> MyProject.Name (as application)
------------|-----> web.config
To do this I build it via Visual Studio Ctrl+Shift+B, then VS deploys it to IIS (creates virtual directory automatically) and that works fine.
But I have many of such projects, which are built via script using msBuild like:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe""C:\Sources\SCgit\MySolution.sln" /t:MyProject_Name /p:Configuration=Debug /clp:ErrorsOnly /verbosity:minimal
from PowerShell and it doesn't create virtual directories when builds project automatically like via VS. That's what I want.
Is there any way to tell msbuild to create such virtual directories using default pre-defined params from properties of VS project MyProject.Name.proj ?
PS
I really can't find the correct question for google, because it always redirects me to topics with a wrong value.
change of web.configs is not a good way for me, because script is a local improvement of personal performance. I need to build about 20+ projects from 10 different solutions for local development

Prevent Visual Studio from automagically changing the physical path of IIS virtual directory?

I have a Visual Studio "solution" which contains a Web application project (among a few other projects). Visual studio "typical" setup seems to be to insist that the output directory for binaries is smack in the root of the project source directory. In particular, each time the web application project is opened, Visual Studio will reset the physical path of the IIS virtual directory to point to the project directory.
This is problematic on many levels:
It's never wise to mix binary output directories and source trees
If the web application is buried deep within a directory hierarchy of other source, wherein many projects produce libraries which may be used as support libraries in the web application, then all the other supporting projects must have their binary output directories set to a bin directory a some non-obvious, nonsensical location somewhere in the source tree.
This "typical" VS setup does not have your web app setup duplicate the "production" setup you would get from a publish: there may be files in your source tree (an old .js file there there from a repository extraction, for example) that are not referenced in your projects, and so would not be in the production published package, but are there in your debugging setup.
It is very possible and very easy to configure all the projects in a Visual Studio solution to build to a bin directory in some subdirectory cleanly placed outside the source tree. It is also easy to ensure that the web app build places all content cleanly in this directory. It is also easy to configure an IIS virtual directory to point to this build output directory. And then Visual Studio, unannounced and unbidden, screws this up by arbitrarily changing the physical directory of the carefully configured virtual IIS app, to point to the middle of one's source tree.
How can this crazy-making behaviour be stopped? I.e. how do I prevent Visual Studio from automagically re-setting the physical path of the virtual web directory each time the web app project is opened?
This question has been asked many times here on Stack Overflow, but I have seen no real answers:
The response to this question (IIS8.5 is automatically changing Physical Path property) simply indicates how to control the order in which Visual Studio does its repointing.
This question and response (Visual Studio creating IIS virtual directories when solution opened) simply confirm the behaviour.
The response to this question (Opening projects changes iis settings) is simply wrong, as are some of the comments.
These questions (Visual Studio 2012 changes IIS application directory without asking), (Visual Studio changes local IIS configuration) have no responses.
Basically, no one has said it can't be done, but no one has give a decent solution either.
I have my application in IIS pointed at %SystemDrive%\inetpub\wwwroot\web, and would like it to stay that way. Like others, I discovered that every time I opened the solution in Visual Studio (I'm using 2017), it would change the application's path in IIS to point to the path that Visual Studio uses.
I've made the following change to the project settings (web tab) for my project. In the servers section, I've set the drop-down to "External Host", and then entered the project URL as https://localhost/web. I'm now able to open the solution in VS without it updating the path in IIS.

Stop Visual Studio 2013 modifying the IISExpress applicationHost.config

I have a website project using Visual Studio 2013, and each time I open it, it keeps adding a new entry for the website project in applicationHost.config. I use IISExpress for my development, however I always create a custom entry to provide some specifics and I have it configured to use port 80, so I would like to not have Visual Studio make any modifications to this file.
I have gone into Tools > Options > Web Projects and unchecked "Use the 64 bit version of IIS Express for web sites and projects", closed the solution, removed the entry from applicationHost.config and re-opened the project in Visual Studio, however it still continues to add an entry to applicationHost.config and name my website project whatever that entry is named.
Is there a way to disconnect Visual Studio entirely from IISExpress? I like using it, but I want to control that service and configuration myself.
Inside the bindings section of the site section, create a new binding in addition to the localhost version like so:
<bindings>
<binding protocol="http" bindingInformation="*:21232:localhost" />
<binding protocol="http" bindingInformation="*:21232:*" />
</bindings>
After having both lines, VS stopped making new site sections.
How to: Specify a Port for the Development Server
I just tried out the method described in the above msdn article to change the port IIS express uses (didn't try 80 though).
right click the website in solution explorer, remove (won't delete files)
edit the applicationHost.config file, change the binding
"add existing web site" in Visual Studio (point to the folder of site you previously removed)
At that point it doesn't seem to create a new entry in applicationHost.config, and uses the new port.
We have the same problem here. Two days googling for a solution without success. The only solution until now is to add the website to the solution using the Local IIS option.
I ran into this trouble when I was switching from one TFS workspace to another while experimenting with VS2013. I'd updated to VS2013 from VS2012 in a new workspace, then when I was done and committed the changes, I got the latest in my original workspace and began to use it there with VS2013. Every time I loaded my web project I got the message about it editing my project file, and every time it did, it screwed up the settings.
Here's how I fixed it, after trying the other answers here. A bad .csproj.user file was the problem. I do not use this file, generally, as I have the "Apply server settings to all users (store in project file)" checkbox in the Web properties checked. But I'd used it in the past. Deleting this file, or updating it so that the settings match those I've set in the project file (i.e. setting the port, whether to use IISExpress, etc.) fixed it. I can now load my project without visual studio making (the wrong) edits to my project file every time I load.
In the project properties, I see a "Web" tab, which contains a "Servers" section that has a dropdown where you can select from the following:
IIS Express
Local IIS
External Host
I believe selecting "Local IIS" is the option you need.
If you don't want to use a local development server, you can attach to an IIS process on a local machine very easily.
There's a way to set the build output location for debug in the properties (right-click project in solution explorer and choose 'properties). If you want to do this easily the first time with no extra setup, just copy your debug build's output to your website folder that you configured in IIS.
Next, ensure you can hit the IIS site. If so, go back to Visual Studio and go to the Debug-> Attach to Process menu item. Choose 'w3wp.exe' out of the list (you may have to check 'view all processes'). You should now be able to hit breakpoints in VS.
However, you should also be able to use IIS Express with a specific port, as #Anssssss said.

Setting Up Visual Studio 2008 Web Site Project In Visual Studio 2010

My development machine was recently upgraded from XP/VS 2008 to Windows 7/VS 2010. I have a Web Site project that I need to continue to run as a Web Site (as opposed to Web Application Project) in 2010. Ideally I'd like the solution files to be in the web root of my system (C:\Webs), but if they're in My Documents, that's fine.
The important part is that I have a folder (called Data, off C:\Webs) that contains roughly 20 GB of .rft and .pdf files, etc., which needs to be on the web root, so the application can access those files, but NOT be part of the build process.
I tried setting up a new blank web site, with the solution in My Documents, but the problem is that when I dragged and dropped the folders from my webs directory (where I need to be running from) into the Solution Explorer window, the actual files were duplicated and copied into the My Documents folder, rather than a "pointer" to the files.
Can someone please tell me how to set up a new Web Site-style project in VS 2010 and include the files from my Webs folder, while allowing me to exclude my Data folder from the overall project, but have the files in it be accessible by the code?
Thanks!
Mike

Every time I open my project I have to create virtual directories

I am currently working on a solution which has an ASP.NET application and a Web Service. Whenever I open this solution I get the message that the virtual directories for this project have not yet been created and must be to continue. The problem is, if I hit OK, it cannot create the directories because they already exist and then I cannot load the project. Looking in IIS I can see that the virtual directory exists in C:/Inetpub/wwwroot/ProjName. If I delete this from IIS, I can then open the project, but it creates the virtual directory in C:/location of project folder. When it uses the project's location, I am not able to connect to the site or the web service.
The same thing happens on XP with IIS 5.1, VS 2010 and Server 2003 with IIS 6.0, VS 2010. Similarly, it happens on colleague's machines, so I am convinced that it is a setting in VS, and not IIS or my machine.
Right now, my solution is to delete the virtual directories, open the VS solution, delete the virtual directories, and publish the projects with the publish toolbar in visual studio (not the web tab in project properties).
I fear that I've at some point messed up a setting on both of the projects, but it has been some time since I've been working around this. I've scoured all of the settings and I can't find anything that fixes this behaviour. I need to pass the project along to someone else, and I feel as if the work around instructions may be confusing so I want to fix this.
I used to do things similarly back in the days when VS didn't have its own dev server - re: directly work on web projects in a local version of IIS (if memory serves, this was called "Personal Web Server" or PWS - am I advertising my age?)
Anyway, I haven't (thankfully) done that since VS (2005?) got its own dev server...
Try this process in VS 2010:
You can develop your solution on any local folder in your file system. You can run/debug your solution from VS (ctrl f5 or f5 respectively) - it will use VS dev server by default. Your development machine doesn't even need to have IIS...
After you are done developing and debugging (using VS and its dev server), you can publish to IIS or even to some other "publish folder" in your (local) file system, and simply copy the files to whatever (local/remote) IIS virtual (ASP.NET application) folder you prefer.

Resources