Reputation: 16081
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).
The path to my file looked like this:
http://localhost:2038/Projects/test.html
But today, when I run it, the ASP.NET Development Server assigned a different port number:
http://localhost:27290/Projects/test.html
Now my redirects don't work. This file is pure a stand-alone file. It is not part of a visual studio web-project or anything. So there are no project settings in visual studio to alter. However I do use visual studio as a text editor. To view the file in the browser I simply right-click over the file in VS2012 and select: 'View in Browser (Google Chrome)'
After I view it in Chrome, Windows 8 pops up a message from the toolbar area informing me that ASP.NET Development Server is running. And it lists the new port too.
How do I change the port to something fixed and not some random value?
Thanks!
Upvotes: 1
Views: 9740
Reputation: 5390
To specify a port for the ASP.NET Development Server:
more info: How to: Specify a Port for the ASP.NET Development Server
Upvotes: 1
Reputation: 12351
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)
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:
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):
So if I ran it via cmd line:
webdev.webserver40 /port:8080 /path:"C:\Users\[my user name]\Desktop" /vpath: "/"
http://localhost:8080/htmlpage1.html
(this file is in my desktop) in any browser...stop
the instance running...Not elegant in any way, so.....
Upvotes: 1
Reputation: 1489
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?
Upvotes: 0