visual-studio 使用网站项目在 Visual Studio Dev Server 上设置静态端口号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1126491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting static port number on Visual Studio Dev Server with a WebSite project
提问by Alex Czarto
I have a WebSite project in Visual Studio 2008 (not a Web Application project!)
我在 Visual Studio 2008 中有一个 WebSite 项目(不是 Web 应用程序项目!)
How do I set the ASP.NET Development startup port to a static port in a WebSite project?
如何在网站项目中将 ASP.NET Development 启动端口设置为静态端口?
回答by backslash17
To specify a port for the ASP.NET Development Server - WebSite / WebServices projects
为 ASP.NET Development Server - WebSite / WebServices 项目指定端口
- In Solution Explorer, click the name of the application.
- In the Properties pane, click the down-arrow beside Use dynamic portsand select False from the dropdown list. This will enable editing of the Port number property.
- In the Properties pane, click the text box beside Port number and type in a port number. Click outside of the Properties pane.This saves the property settings.
- Each time you run a file-system
Web site within Visual Web Developer, the ASP.NET
Development Server will listen on the specified port.
- 在解决方案资源管理器中,单击应用程序的名称。
- 在“属性”窗格中,单击“使用动态端口”旁边的向下箭头,然后从下拉列表中选择“假”。这将启用端口号属性的编辑。
- 在“属性”窗格中,单击端口号旁边的文本框并输入端口号。在“属性”窗格外部单击。这将保存属性设置。
- 每次在 Visual Web Developer 中运行文件系统网站时,ASP.NET
开发服务器都会侦听指定的端口。
回答by Neeraj Gulia
Press F4 to get the Properties Pane. And then one can get the option mentioned by Backslash17
按 F4 以获取属性窗格。然后可以得到Backslash17 提到的选项
回答by Ozgur
For web site assigning port is not possible form VS Properties Page interface but if you start your web site from command linethen you can assign the port (If you want to debug the site you can attach after starting the web site)
对于网站分配端口是不可能的形式 VS 属性页面界面,但如果您从命令行启动您的网站,那么您可以分配端口(如果您想调试网站,您可以在启动网站后附加)
WebDev.WebServer40.exe
WebDev.WebServer40.exe
path is
路径是
"C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\" or "C:\Program Files\Common Files\microsoft shared\DevServer\10.0\"
“C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\”或“C:\Program Files\Common Files\microsoft shared\DevServer\10.0\”
ASP.NET Development Server Usage: WebDev.WebServer40 /port: /path: [/vpath:]
ASP.NET 开发服务器用法:WebDev.WebServer40 /port: /path: [/vpath:]
Example:
例子:
WebDev.WebServer40 /port:8080 /path:"c:\inetpub\wwwroot\MyApp" /vpath:"/MyApp"
WebDev.WebServer40 /port:8080 /path:"c:\inetpub\wwwroot\MyApp" /vpath:"/MyApp"
回答by dxbmatt
It can't be done with a Website project, the port number is randomly assigned.
一个网站项目不行,端口号是随机分配的。
It's only possible with a Web App Project
仅适用于 Web 应用程序项目

