简体   繁体   English

Visual Studio 2015重置Web项目以使用IIS Express

[英]Visual Studio 2015 resetting web project to use IIS Express

I have a web project in VS2015 that I want to run on Local IIS. 我在VS2015中有一个我想在本地IIS上运行的Web项目。 I set this up in the project properties and it works correctly, but whenever I close and reopen Visual Studio it always resets the project to use IIS Express. 我在项目属性中设置它并且它可以正常工作,但每当我关闭并重新打开Visual Studio时,它总是重置项目以使用IIS Express。

EDIT: this happens when I close and reopen the solution, even if Visual Studio has stayed open. 编辑:当我关闭并重新打开解决方案时,即使Visual Studio保持打开,也会发生这种情况。

Why is this happening, and how can I change it? 为什么会发生这种情况,我该如何改变呢? (Note - other users are working on the same project so I don't want to store my Local IIS settings in the project file as I assume this would overwrite their settings when they got the latest version of the code.) (注意 - 其他用户正在处理同一个项目,所以我不想将我的本地IIS设置存储在项目文件中,因为我认为这会在他们获得最新版本的代码时覆盖他们的设置。)

I edited the .csproj.user file and this fixed the problem. 我编辑了.csproj.user文件,这解决了这个问题。 I changed <UseIISExpress>true</UseIISExpress> to <UseIISExpress>false</UseIISExpress> and left everything else the same. 我将<UseIISExpress>true</UseIISExpress>更改为<UseIISExpress>false</UseIISExpress>并将其他所有内容保留为相同。

I still don't know why doing this through the UI didn't save, if anyone else can explain it I'll happily accept their answer. 我仍然不知道为什么通过用户界面这样做没有保存,如果其他人可以解释它我会很乐意接受他们的答案。

NibblyPig pointed out in their comment that: NibblyPig在评论中指出:

it appears that if you don't change the URL then it doesn't save the setting. 看来,如果您不更改URL,则它不会保存设置。 So I changed my Project Url, pressed save, then changed it back and pressed save again and it updated the file. 所以我更改了我的Project Url,按了save,然后将其更改回来并再次按下save并更新了文件。

I'm just putting this as an answer so it's easier to find, but full credit to NibbyPig for finding this. 我只是把它作为一个答案,所以它更容易找到,但NibbyPig完全赞同这一点。

Delete the file projectName.csproj.user . 删除文件projectName.csproj.user User specified preferences in this file overwrite the project settings. 此文件中用户指定的首选项会覆盖项目设置。

If you don't save settings how would you expect to persist it and be available when next time you open project? 如果您不保存设置,您希望如何保留它并在下次打开项目时可用? I understand your concern that your settings shouldn't affect other team members who are working on same project. 我理解您担心您的设置不应影响正在处理同一项目的其他团队成员。 Your concern can be taken care if you follow below steps. 如果您按照以下步骤操作,则可以小心谨慎。 Whatever settings you will do will remain local and applicable to you only and other team members will not get impacted. 无论您做什么设置都将保留在本地并且仅适用于您,其他团队成员不会受到影响。

  1. Go to project properties. 转到项目属性。
  2. Go to Web tab on property page. 转到属性页面上的Web选项卡。
  3. Untick "Apply server settings to all users as shown below. 取消“将服务器设置应用于所有用户,如下所示。 Web项目设置
  4. Click Save button in toolbar. 单击工具栏中的保存按钮。

    This way your settings will be stored in xxxx.user file and not in project file. 这样,您的设置将存储在xxxx.user文件中,而不是存储在项目文件中。

This is what worked for me using VS 2015 Update 3. This is related to what NibblyPig said. 这对我使用VS 2015 Update 3有用。这与NibblyPig所说的有关。 But for me only worked when editing the project file directly. 但对我来说,只有在直接编辑项目文件时才有效。

  1. Unload the project. 卸载项目。 (If the project is not loading at all just go to #2) (如果项目根本没有加载,只需转到#2)
  2. Edit project file. 编辑项目文件。 The only entry that needs to be changed is (almost at the end of the file) <IISUrl> . 唯一需要更改的条目是(几乎在文件的末尾) <IISUrl> There is no need to mess with <UseIISExpress> configuration, you can leave it as it is. 没有必要弄乱<UseIISExpress>配置,您可以保持原样。

An entry for IISExpress will look similar to this one: IISExpress的条目看起来与此类似:

<IISUrl>http://localhost:123456</IISUrl>

Change it to something like this one: 把它改成这样的东西:

<IISUrl>http://localhost/your_site_in_iis</IISUrl>

Note: "your_site_in_iis" should be an existing website. 注意:“your_site_in_iis”应该是现有网站。

  1. Save and close project file. 保存并关闭项目文件。
  2. Close the solution (this one is important). 关闭解决方案(这个很重要)。
  3. Open the solution again and the problem should go away. 再次打开解决方案,问题应该消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IIS Express“指定的端口正在使用中”Visual Studio 2015 - IIS Express 'The specified port is in use' Visual Studio 2015 Visual Studio 2015 Update 3:“此项目使用SQL Server Express LocalDB。 Microsoft建议您将SQL Server Express与IIS一起使用“ - Visual Studio 2015 Update 3: “This project uses SQL Server Express LocalDB. Microsoft recommends that you use SQL Server Express with IIS” Visual Studio 2015 Web Express - Visual Studio 2015 Web Express 如何在Visual Studio Express 2013中通过本地IIS运行Web项目 - How to run web project by local IIS in visual studio express 2013 在Visual Studio 2013中的IIS Express上托管多个Web项目 - Multiple web project are hosted on IIS Express in Visual Studio 2013 在Visual Studio 2015中使用IIS服务器而不是IIS Express - Using IIS Server instead of IIS Express in Visual Studio 2015 Visual Studio 2015 Update 1 - 调试时没有IIS Express响应 - Visual Studio 2015 Update 1 - No IIS Express Response While Debugging Visual Studio 2015:IIS Express中的自定义域 - 无效的主机名 - Visual Studio 2015: Custom Domains in IIS Express - Invalid Hostname Visual Studio 2015 Web API 2项目挂起 - Visual Studio 2015 Web API 2 Project hanging 与2015年相比无法在特定项目上启动IIS Express Web服务器 - Unable to launch the IIS Express Web server on specific project in vs 2015
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM