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

前端 未结 3 1976
野趣味
野趣味 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:42

    To specify a port for the ASP.NET Development Server:

    1. In Solution Explorer, click the name of the application.
    2. In the Properties pane, click the down-arrow beside Use dynamic ports and select False from the dropdown list. This will enable editing of the Port number property.
    3. In the Properties pane, click the text box beside Port number and type in a port number.
    4. 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.

    more info: How to: Specify a Port for the ASP.NET Development Server

    0 讨论(0)
  • 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.....

    0 讨论(0)
  • 2021-01-23 15:56

    If you're using VS, you can create a project with just an HTML file (and whatever other non-.NET things you need). From there you can set the port under the project settings. I understand that you're using VS just as the text editor (I do the same thing all of the time), but if you want to set the port, that's how you're going to need to do it because otherwise VS is going to pick a port unless the project file (which is missing) tells it to use a specific port. If you use the "open in browser" feature, it actually launches the web server and uses that to host the HTML file.

    An alternative would be to edit/save in Visual Studio and open the file in your browser for testing. This will work because it's an HTML file and you don't need a webserver to view it.

    my redirects don't work

    The port shouldn't effect your redirects unless you're specifically referencing a protocol and port...but you shouldn't need to do that. Can you post your code or give an explanation as to what's happening here?

    0 讨论(0)
提交回复
热议问题