在 Visual Studio 2013 中更改项目端口号 [英] Changing project port number in Visual Studio 2013

查看:52
本文介绍了在 Visual Studio 2013 中更改项目端口号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 Visual Studio 2013 中更改项目端口号?
我使用的是 ASP.Net,我需要在 Visual Studio 2013 中调试时更改端口号.

How can I change the project port number in Visual Studio 2013 ?
I'm using ASP.Net and I need to change the port number while debugging in Visual Studio 2013.

推荐答案

VS 中的 ASP.NET 项目有两种项目类型:

There are two project types in VS for ASP.NET projects:

Web 应用程序项目(特别是有一个 .csproj 或 .vbproj 文件来存储这些设置)在项目下有一个属性节点.在 Web 选项卡上,您可以配置项目 URL(假设是 IIS Express 或 IIS)以使用您想要的任何端口,然后只需单击创建虚拟目录按钮.这些设置保存到项目文件中:

Web Application Projects (which notably have a .csproj or .vbproj file to store these settings) have a Properties node under the project. On the Web tab, you can configure the Project URL (assuming IIS Express or IIS) to use whatever port you want, and just click the Create Virtual Directory button. These settings are saved to the project file:

<ProjectExtensions>
  <VisualStudio>
    <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
      <WebProjectProperties>
       <DevelopmentServerPort>10531</DevelopmentServerPort>
       ...
     </WebProjectProperties>
    </FlavorProperties>
  </VisualStudio>
</ProjectExtensions>

网站项目是不同的.他们没有 .*proj 文件来存储设置;相反,这些设置是在 solution 文件中设置的.在 VS2013 中,设置如下所示:

Web Site Projects are different. They don't have a .*proj file to store settings in; instead, the settings are set in the solution file. In VS2013, the settings look something like this:

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebSite1(1)", "http://localhost:10528", "{401397AC-86F6-4661-A71B-67B4F8A3A92F}"
    ProjectSection(WebsiteProperties) = preProject
        UseIISExpress = "true"
        TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.5"
        ...
        SlnRelativePath = "....WebSitesWebSite1"
        DefaultWebSiteLanguage = "Visual Basic"
    EndProjectSection
EndProject

因为项目是由 URL(包括端口)标识的,所以在 VS UI 中没有办法改变它.不过,您应该能够修改解决方案文件,它应该可以工作.

Because the project is identified by the URL (including port), there isn't a way in the VS UI to change this. You should be able to modify the solution file though, and it should work.

这篇关于在 Visual Studio 2013 中更改项目端口号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆