Get URL to newly created Virtual Directory

S

scottieyoon

I created virtual directory in my custom setup project successfully.
However, I would like to get actual URL to the directory so I need to
convert .....

DirectoryEntry entry = new DirectoryEntry(@"IIS://localhost/W3SVC/1/
Root/MyApp");

to

http://myserver/MyApp

I check all properties in DirectoryEntry but none points to actual
URL. Can you help, please?
 
N

Nicholas Paldino [.NET/C# MVP]

I don't know that you can do that, since IIS can host on multiple
adapters, each of which corresponds to different IP addresses, which
theoretically, could map to separate DNS names.

You will have to get the adapters that you want to get the URLs for, and
then do a reverse lookup on the IP address, getting the DNS name. That
should help you with constructing the full URL you are looking for. Since
you already have the application entry, you should be able to get the
virtual directory for your app, and then tack it onto the DNS name.
 
S

scottieyoon

I was afraid of answer like that. I'm ok with installing only on
"Default Web Site", so if I can just get the machine name then append
the virtual directory name, as in,

http://mymachine/myapp

then I should be good to go. I know little about DNS but won't it be
always the same as the machine name?

    I don't know that you can do that, since IIS can host on multiple
adapters, each of which corresponds to different IP addresses, which
theoretically, could map to separate DNS names.

    You will have to get the adapters that you want to get the URLs for, and
then do a reverse lookup on the IP address, getting the DNS name.  That
should help you with constructing the full URL you are looking for.  Since
you already have the application entry, you should be able to get the
virtual directory for your app, and then tack it onto the DNS name.

--
          - Nicholas Paldino [.NET/C# MVP]
          - (e-mail address removed)




I created virtual directory in my custom setup project successfully.
However, I would like to get actual URL to the directory so I need to
convert .....
DirectoryEntry entry = new DirectoryEntry(@"IIS://localhost/W3SVC/1/
Root/MyApp");


I check all properties in DirectoryEntry but none points to actual
URL.  Can you help, please?- Hide quoted text -

- Show quoted text -
 
N

Nicholas Paldino [.NET/C# MVP]

If this is for an intranet, then yes, you can use the NETBIOS name
(machine name) and then create the URL from that. If you are talking about
external access, then you would have to do a reverse DNS lookup (or just
hard code the associations if you know them).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I was afraid of answer like that. I'm ok with installing only on
"Default Web Site", so if I can just get the machine name then append
the virtual directory name, as in,

http://mymachine/myapp

then I should be good to go. I know little about DNS but won't it be
always the same as the machine name?

I don't know that you can do that, since IIS can host on multiple
adapters, each of which corresponds to different IP addresses, which
theoretically, could map to separate DNS names.

You will have to get the adapters that you want to get the URLs for, and
then do a reverse lookup on the IP address, getting the DNS name. That
should help you with constructing the full URL you are looking for. Since
you already have the application entry, you should be able to get the
virtual directory for your app, and then tack it onto the DNS name.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)




I created virtual directory in my custom setup project successfully.
However, I would like to get actual URL to the directory so I need to
convert .....
DirectoryEntry entry = new DirectoryEntry(@"IIS://localhost/W3SVC/1/
Root/MyApp");


I check all properties in DirectoryEntry but none points to actual
URL. Can you help, please?- Hide quoted text -

- Show quoted text -
 
S

scottieyoon

It is only for Intranet. I tested out the scenario and it works as
described. I'm ok with the solution. Thank you for your input.

Scott

    If this is for an intranet, then yes, you can use the NETBIOS name
(machine name) and then create the URL from that.  If you are talking about
external access, then you would have to do a reverse DNS lookup (or just
hard code the associations if you know them).

--
          - Nicholas Paldino [.NET/C# MVP]
          - (e-mail address removed)


I was afraid of answer like that.  I'm ok with installing only on
"Default Web Site", so if I can just get the machine name then append
the virtual directory name, as in,

http://mymachine/myapp

then I should be good to go.  I know little about DNS but won't it be
always the same as the machine name?

I don't know that you can do that, since IIS can host on multiple
adapters, each of which corresponds to different IP addresses, which
theoretically, could map to separate DNS names.
You will have to get the adapters that you want to get the URLs for, and
then do a reverse lookup on the IP address, getting the DNS name. That
should help you with constructing the full URL you are looking for. Since
you already have the application entry, you should be able to get the
virtual directory for your app, and then tack it onto the DNS name.
- Show quoted text -- Hide quoted text -

- Show quoted text -
 

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