How to fix a port number in asp.NET development server

前端 未结 3 1981
野趣味
野趣味 2021-01-23 15:10

Yesterday I was writing a stand-alone .html web-page. Every time I viewed it, the file was run in the local host. Thus a port number was assigned by my OS (Windows 8).

3条回答
  •  鱼传尺愫
    2021-01-23 15:55

    I simply right-click over the file in VS2012 and select: 'View in Browser (Google Chrome)'

    Doing so in Visual Studio fires up the ASP.net Dev server. It's not Windows that assigns it (nor configures it)

    • How to specify a port for ASP.net Dev Server no project/solution to speak of, it's just some file on file system....

    Update: Unsure if this will be a solution for you:

    If you click the "wrench" icon of the dev server in your tray, you will see this: Dev Server tray

    The executable is in: c:\Program Files (x86)\Common Files\microsoft shared\DevServer\11.0> (for VS 2012)

    If you run it via cmd line, this will pop (instructions): ASP.Net Dev Server exe

    So if I ran it via cmd line:

    webdev.webserver40 /port:8080 /path:"C:\Users\[my user name]\Desktop" /vpath: "/"

    • the dev server will run on the specified port (8080)
    • treat my desktop as the "root"
    • allowing me to type: http://localhost:8080/htmlpage1.html (this file is in my desktop) in any browser...
    • until I stop the instance running...

    Not elegant in any way, so.....

提交回复
热议问题