Stop Visual Studio 2013 modifying the IISExpress applicationHost.config - visual-studio

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.

Related

What is the XspParameters element that Visual Studio for Mac adds to a .csproj file?

My team has an ASP.NET project that was originally created in Visual Studio on Windows, and has only ever been developed in that environment up to this point. Today, I opened that project for the first time in Visual Studio for Mac (version 7.6 build 711), and added a new file to the project.
After doing that, while looking at the diff on the pull request, my team noticed this new addition to the .csproj file, evidently made by Visual Studio for Mac:
<MonoDevelop>
<Properties>
<XspParameters Port="8080" Address="127.0.0.1" SslMode="None" SslProtocol="Default" KeyType="None" CertFile="" KeyFile="" PasswordOptions="None" Password="" Verbose="True" />
</Properties>
</MonoDevelop>
What is this? What does it do?
Should we manually remove it, given that the application will continue to only ever be hosted in Windows environments?
(I suspect it is probably harmless? On the other hand, I'd like to understand what it is before putting a project built with that element present into production; I'm leery about the Passsword="", for example, potentially manifesting some kind of security hole.)
These are just the settings that are used when running the ASP.NET project with Mono's ASP.NET hosting server (XSP). You can remove these properties.
Testing this and it seems that these properties are added to the project if you open the Project Options dialog and then click the OK button. Ideally if the values match the defaults then this should not be added to the project file.
It would probably make sense for Visual Studio for Mac to store this information in the same way as run configurations are in the .user file instead of adding it to the main project.

Make Localhost a Custom Domain in IIS Express

I am using IIS Express in Visual Studio 2010 and right now it runs on localhost:61156. But I need it to run on a domain. Is it possible to make IIS Express to run on devserver.com, instead of localhost:61156? So basically when I run debug I want devserver,com, instead of localhost:61156. I've come across a few things on google, but no luck. Any ideas on how to do this?
Thanks!
Do the following
If IIS Express is running stop it
Open your webapplication project file (*.csproj or *.vbproj)
Find <IISUrl>http://localhost:61156/</IISUrl> and change it to <IISUrl>http://devserver.com:61156/</IISUrl>
Open %userprofile%\documents\iisexpress\config\applicationhost.config file
Visual Studio 2015 now puts an applicationhost.config file specific to your project instead of using the global one. It is located at: /path/to/code/root/.vs/config/applicationhost.config
Find your site entry in applicationhost.config file change the binding as shown below
<binding protocol="http" bindingInformation="*:61156:devserver.com" />
In \Windows\system32\drivers\etc\hosts file add following mapping "127.0.0.1 devserver.com"
In your browser add exception to bypass proxy for devserver.com
Note that, since you are using custom domain (non localhost binding), you must run visual studio as Administrator
#vikomall's answer is the correct one, but I don't have enough reputation to comment yet, so I'm adding an extra answer here with a clarification for Visual Studio 2015.
Visual Studio 2015 now puts an applicationhost.config file specific to your project instead of using the global one. It is located at:
/path/to/code/root/.vs/config/applicationhost.config
Follow the same steps as #vikomall's answer, but use the path above for step #4.
See Mike Dice's Blog

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.

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

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?

Why does it say "Project with that name already opened in the solution"?

I recently migrated a VSS database to TFS 2008. Using Source Control Explorer, I got the latest version of a solution with 12 projects.
When I opened the solution in VS 2005, two of the projects were not found. I am not sure why these two projects were not found, but thought it easiest to just delete and re-add them to the solution.
When I do this, VS gives me a "A project with that name is already open in the solution." The project doesn't appear in solution explorer, and is not listed in the .sln file.
Any ideas?
I had this problem and I was able to solve it using the following steps:
Remove the project from the solution.
restart visual studio.
add the project to the solution as an existing project.
I had the same message... Seems like it comes from (.csproj) project file. Under first propertygroup there is a section named
<ProjectTypeGuids>...</ProjectTypeGuids>
which generally tells Visual Studio to handle that project in some specific way. Some Guids can be found here.
First make a backup copy of that file. Then removing that section can help you open the project as usual project. As it seems that the Visual Studio thinks that the project is not the type that is specified in the ProjectTypeGuids.
This did it for me:
remove the section <ProjectTypeGuids>...</ProjectTypeGuids> in each project
reopen each project, then save to overwrite the existing project file, finally exit
reopen the solution file
pray (optional)
If anyone uses AnkhSVN instead of TFS, it's also possible, that the .sln-file need the following lines:
GlobalSection(SubversionScc) = preSolution
Svn-Managed = True
Manager = AnkhSVN - Subversion Support for Visual Studio
EndGlobalSection
in the "Global" section.
Before anyone tries tempering with their solution- and project files, figure if you may have project dependencies outside the solution, such as IIS - and you forgot to start Visual Studio in Administrator-mode
For me, the project not loaded was because it was configured to use IIS on the local machine and I needed to start Visual Studio as an Administrator.
I have to say that removing the section <ProjectTypeGuids>...</ProjectTypeGuids> could create some problems.
In fact, such a section defines the type of the project and, if removed, could disable some features.
For example, if your project was originally defined as Smart Device (C#), after removing the aforementioned section the on-device debug may not working properly.
Delete .suo file. Build solution. Add Projects.
Unfortunately I don't know the why behind the obtuse error message, I can merely provide what steps I took to get it to go away.
In my case, I had reconfigured my local IIS (<UseIIS> not <UseIISExpress>) and it was no longer hosting the URL that was in the csproj <IISUrl> field.
Editing the .csproj file in another editor and changing that field to the new URL, followed by closing and opening the solution in VS resolved the issue.
I would try hand editing the project/solution files, they are text and pretty easy to read. You can edit the file in notepad. To open up the file as text in visual studio you need to first close the solution. Then do file->open and select the sln file, but instead of hitting the open button, press on the right side where there is an arrow and select open with.. from there you can select source code editor (text).
Somehow VS 2022 doesn't create a virtual directory anymore. I had to manually create the website in IIS
I had the same problem when i migrated a website to a web app project.
Unload the web app.
Add the existing website.
Reload the web app.
The following worked for me when I moved a project running vs2010 to another laptop.
I removed exactly the following and it worked:
<ProjecctType>Guid of sorts</ProjectType>
<SccProjectName>Svn</SccProjectName>
<SccLocalPath>Svn</SccLocalPath>
<SccAuxPath>Svn</SccAuxPath>
<SccProvider>SubversionScc</SccProvider>
For those looking for this while dealing with VSTO projects...
Be sure to have the Office Tools for Visual Studio installed in your machine before opening the project.
I solved it by changing Windows' regional settings. Instead of "English (Europe)", I used "English (United States)". Others have reported similar behaviors with changing for example from "Russian (Ukraine)" to "Russian (Russia)", etc.
-AlessandroSegala
Work For me.
Ref: http://answers.microsoft.com/en-us/windows/forum/windows_10-windows_install/customized-cultures-cannot-be-passed-by-lcid-only/26eb9d4b-7ddb-4774-8a40-7a7d84ba9277?auth=1&rtAction=1455534187354
In my case it was corrupted vbproj file. First line was missing:
<?xml version="1.0" encoding="utf-8"?>
After adding this line I had to close the solution, delete .vs folder and open again.
I got it in Visual Studio 2022 version 17.4.4.
You may also see:
Error HRESULT E_FAIL has been returned from a call to a COM
component.
when you try to reload your project.
One way to load the project (and deal with IIS directories later) is to edit the .csproj file and set UseIISExpress to true.
Replace:
<UseIISExpress>false</UseIISExpress>
with
<UseIISExpress>true</UseIISExpress>
Then you need to close your solution and open it again and the project should load.
I encountered this issue with web application projects.
When I tried to reload the projects, the VS2022 output said something like :
"The project is configured to use IIS. Unable to find the server
'{site_url}' on the local computer. Ensure that the local IIS is
configured to handle secure communications."
Which is pretty clear. Indeed, in my case, this was caused by my website https binding that just vanished for no reason (it happened to me several times, looks like a bug with Windows 11 & IIS 10). Things got fixed when I got my https binding back (projects could load norammly).
In VS 2022 to open a legacy web project I had to:
Remove from Solution
Change framework version from 4.6.x to <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> in from csproj
Remove <OutputType>Library</OutputType> from csproj
Close Solution and open it again (!!!)
Add project to the sln again.

Resources