How to make a HttpWebRequest without specifying the port no?

N

nasayoo

I make a HttpWebRequest to the web which is hosted in the local host from my
C# application by the following code:


HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create("http://localhost:1035/Web/LogIn.aspx");

But every time I start the server the port no is changing which makes
changes to the above code. How can I get rid of it. Can't I make the request
without specifiying the port no? How can I make the above string independent
from the server port no?

Thanks in advance

Hope to see an answer soon.
 
N

nasayoo

Configure your server so that it always uses the standard HTTP port: 80.
How to cofigure the server??


Peter Duniho said:
[...]
But every time I start the server the port no is changing which makes
changes to the above code. How can I get rid of it. Can't I make the
request
without specifiying the port no?

Yes, but the server has to be on the standard HTTP port, 80.
How can I make the above string independent
from the server port no?

Configure your server so that it always uses the standard HTTP port: 80.

Pete
 
N

nasayoo

As a simple way, I just edited the solution file of my webproject like below,
VWDPort = "80"
Now when I run the project, its running on the localhost - port 80. But I
have a doubt whether this change is permanent or not.
Btw: when I deploy it(I am going to deploy it in another machine), will it
change?
 
P

Pavel Minaev

nasayoo said:
As a simple way, I just edited the solution file of my webproject like
below,
VWDPort = "80"
Now when I run the project, its running on the localhost - port 80. But I
have a doubt whether this change is permanent or not.
Btw: when I deploy it(I am going to deploy it in another machine), will it
change?

When you deploy it, you won't be using the VSW embedded testing Web server,
obviously. So it will depend on the way the production Web server you're
deploying it to is configured.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top