Re: How does asp.net 2.0 allocate port numbers on localhost

Adam Sills <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.web
Message-ID <[email protected]>
It's non-random port allocation from the ephemeral port range (1024-4999).
Windows takes care of this port allocation. You ask for one, and it gives
you the next available port. Visual Studio just does its best to reuse any
port it was previously given by Windows, to help avoid the need to update
web references, etc.

FYI, you can do the same manually through .NET code:

TcpListener listener = new TcpListener( 0 ); // specify port 0, or "give me
any port"

Adam..

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:[email protected]] On Behalf Of Paul van Brenk
Sent: Thursday, November 23, 2006 10:03 AM
To: [email protected]
Subject: Re: [DOTNET-WEB] How does asp.net 2.0 allocate port numbers on
localhost

Probably... get random number, check for availability, repeat until you
have good one? I don't think there is an actual system involved.

Paul

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:[email protected]] On Behalf Of Manoj Aggarwal
Sent: Thursday, November 23, 2006 16:47
To: [email protected]
Subject: Re: [DOTNET-WEB] How does asp.net 2.0 allocate port numbers on
localhost

Yes I can do that... but not sure enough if it works fine for me... Hope
it
helps. Also can someone please explain

How does port allocation mechanism work on asp.net
development webserver

-----Original Message-----
From: Discussion of building .NET applications targeted for the Web
[mailto:[email protected]] On Behalf Of Ryan Heath
Sent: Thursday, November 23, 2006 04:37 PM
To: [email protected]
Subject: Re: [DOTNET-WEB] How does asp.net 2.0 allocate port numbers on
localhost

Is it possible for you to change the property : use dynamic ports into
false?

HTH
// Ryan

On 11/23/06, Manoj Aggarwal <[email protected]> wrote:
> This property is disabled.......
>
> I am specifying my problem more elaborately
>
> Here is what am I doing?
>
> I am having 2 Projects in Solution explorer.
>
> Project 1 is a webservices project stored on the file system running
on
> asp.net development webserver with port allocated as 1480.
>
> Project 2 is a windows based application having the webreferences of
> webservices present in Project 1 like this
> http://localhost:1480/Server/HelloWorld.asmx
>
> Now the problem is that whenever asp.net allocates the port number
> dynamically to the websites running on development webserver.
>
> So what happens is whenever the localhost:1480 port changes to
> localhost:1907 or any other port number, I have to change all the
> webreferences present in Project 2. If there are 20 Webreferences then
I
> have to update 20 webreferences which is very tedious task. However I
can
> also update my app.config file with the new port number and make
application
> running. But the problem is that I won't be able to debug the
webservices.
>
> What I want is
>
> 1. I should be able to fix the port number of asp.net development
webserver
> for an particular website.
>
> 2. I want to know how does this port allocation mechanism work on
asp.net
> development webserver
>
> Thanks
> Manoj.
>
>
> -----Original Message-----
> From: Discussion of building .NET applications targeted for the Web
> [mailto:[email protected]] On Behalf Of Ryan Heath
> Sent: Thursday, November 23, 2006 03:44 PM
> To: [email protected]
> Subject: Re: [DOTNET-WEB] How does asp.net 2.0 allocate port numbers
on
> localhost
>
> The properties window has the port options.
> Select your web project and if the properties window is not visible
> press CTRL+W, P
>
> HTH
> // Ryan
>
> On 11/23/06, Paul van Brenk <[email protected]> wrote:
> > If you use a web-application project you can assign which
port-number
> > the build in server should use...  Strange that this isn't an option
in
> > the default 'website project'...maybe it's hidden somewhere?
> >
> > Paul
> >
> > -----Original Message-----
> > From: Discussion of building .NET applications targeted for the Web
> > [mailto:[email protected]] On Behalf Of Manoj Aggarwal
> > Sent: Thursday, November 23, 2006 10:07
> > To: [email protected]
> > Subject: Re: [DOTNET-WEB] How does asp.net 2.0 allocate port numbers
on
> > localhost
> >
> > I am using VS2005, But the problem with using IIS is that I have to
> > enable
> > remote debugging which is not very comfortable one. Having a website
on
> > the
> > file system allows me to debug more easily and fast. What I want to
know
> > is
> > that "I should be able to fix the port number for my website, so
that it
> > never keeps changing. Also I want to know how asp.net allocate the
port
> > number to the web server".
> >
> > Thanks,
> > Manoj Aggarwal.
> >
> > -----Original Message-----
> > From: Discussion of building .NET applications targeted for the Web
> > [mailto:[email protected]] On Behalf Of Efran Cobisi
> > Sent: Thursday, November 23, 2006 01:49 PM
> > To: [email protected]
> > Subject: Re: [DOTNET-WEB] How does asp.net 2.0 allocate port numbers
on
> > localhost
> >
> > Hi,
> >
> > Assuming you are using Visual Studio 2005, it could depends on the
fact
> > that, for file system Web sites, whenever you "start" a web site it
> > launches the ASP.NET Development server, which could change the port
it
> > binds to. I suggest you to configure your project as an IIS web site
and
> > set it as the "server" in the start options dialog box; it should
always
> > use the same - default - port.
> > See http://msdn2.microsoft.com/en-us/ms178730(vs.80).aspx for
additional
> > infos.
> >
> > HTH,
> >
> > Efran Cobisi
> >
> > Manoj Aggarwal wrote:
> > > Dear Friends,
> > >
> > >         I am working on a project based on Webservices and windows
> > forms.
> > My
> > > problem is that when I open the solution, sometimes the
webservices
> > starts
> > > on a different port number. For instance: earlier my webservices
> > application
> > > was running on localhost:1907 and next day I start it may run on
> > > localhost:1480. This becomes very problematic as I would have
given
> > the
> > > webreferences with port number 1907. And changing the port number
for
> > each
> > > and every webservice is a tedious task. Do any body have a
solution to
> > fix
> > > the localhost port number. Also I would like to know about how
asp.net
> > 2.0
> > > deals with port numbers.
> > >
> > > Thanks,
> > > Manoj Aggarwal.
> > >
> > > -----Original Message-----
> > > From: Discussion of building .NET applications targeted for the
Web
> > > [mailto:[email protected]] On Behalf Of Dean Cleaver
> > > Sent: Tuesday, November 14, 2006 03:07 AM
> > > To: [email protected]
> > > Subject: [DOTNET-WEB] And for another problem
> > >
> > > Completely different page this time (actually it's a UserControl,
not
> > a
> > > page) and it's taking about 1 minute to create each control to
design
> > > the page. It's been going for about 30 minutes now at 50%CPU
(hyper
> > > threaded, so that's all it can).
> > >
> > > Dino
> > >
> > > ===================================
> > > This list is hosted by DevelopMentor.  http://www.develop.com
> > >
> > > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> > >
> > > ===================================
> > > This list is hosted by DevelopMentorR  http://www.develop.com
> > >
> > > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> > >
> >
> > ===================================
> > This list is hosted by DevelopMentorR  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> > http://discuss.develop.com
> >
> > ===================================
> > This list is hosted by DevelopMentor(r)  http://www.develop.com
> >
> > View archives and manage your subscription(s) at
> http://discuss.develop.com
> >
>
> ===================================
> This list is hosted by DevelopMentorR  http://www.develop.com
>
> View archives and manage your subscription(s) at
http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentorR  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentor.  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.