可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
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.
回答2:
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.
回答3:
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.
回答4:
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.
回答5:
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.
回答6:
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.