1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Default Web Site : Virtual Directory

Discussion in 'C#' started by red_fiesta, Oct 25, 2006.

  1. #1
    Is there a way in asp to create a new default web site within IIS

    I am setting a content managament system and want to create a new default web site during on of the processes.

    So for example if people create a new site within the admin section and call it Jacinto this will create a new virtual directory called Jacinto.

    This would then be accessed at http://localhost/jacinto

    Thanks

    red_fiesta
     
    red_fiesta, Oct 25, 2006 IP
  2. red_fiesta

    red_fiesta Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I have tried this code

    <%
    '''''''''''''''''''''''''''''''''
    ' ADSI ASP Sample Program
    ' This is a sample of how to create a virtual directory using ADSI.
    '
    '''''''''''''''''''''''''''''''''
    Option Explicit
    On Error Resume Next

    '''''''''''''''''''''''
    ' First, open the path to the Web server you are
    ' trying to add a virtual directory to.

    Dim ServObj
    Dim VdirObj
    Dim Testpath

    Set ServObj = GetObject("IIS://LocalHost/w3svc/1/Root")
    if (Err <>0) then
    Response.Write "GetObject (""IIS://LocalHost/w3svc/1/Root"") Failed! <br>"
    Response.Write "Error! " & Err.Number & "(" & Hex(Err.Number) & "): " & Err.Description & "<br>"
    Response.End
    end if

    '''''''''''''''''''''''
    ' Second, Create the virtual directory (Vdir) path
    Set VdirObj = ServObj.Create("IIsWebVirtualDir", "MyVdir")
    VdirObj.SetInfo
    if (Err<>0) then
    Response.Write "CreateObject (""IIS://LocalHost/w3svc/1/Root/MyVdir"") Failed!<br>"
    Response.Write "Error! " & Err.Number & "(" & Hex (Err.Number) & "): " & Err.Description &

    "<br>"
    Response.End
    end if

    ''''''''''''''''''''''''
    ' Finally, create a Path variable containing the virtual root path and
    ' set the permissions to read, script, and directory browsing
    VdirObj.AccessRead = True
    VdirObj.AccessScript = True
    VdirObj.EnableDirBrowsing = True
    Testpath = "C:\Temp"
    VdirObj.Put "Path", (Testpath)

    VdirObj.SetInfo
    if (Err<> 0) then
    Response.Write "Put (""Path"") Failed!"
    Response.Write "Error! " & Err.Number & "(" & Hex (Err.Number) & "): " & Err.Description &

    "<br>"
    Response.End
    end if

    Response.Write "VDIR successfully created"

    ''''''''''''''''''''''''
    ' The minimum amount necessary to create a virtual directory has now
    ' been completed. If you need to add more, do it here.

    %>

    from http://msdn2.microsoft.com/en-us/library/ms951564.aspx

    But i get

    GetObject ("IIS://LocalHost/w3svc/1/Root") Failed!
    Error! 70(46): Permission denied

    I have put this file in a dir and given it all permssions..

    please help

    This is vital
     
    red_fiesta, Oct 25, 2006 IP
  3. Garve

    Garve Peon

    Messages:
    62
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi red_fiesta

    I tried to get this to work about 10 months ago but failed, since when I've created 950 virtual directories by hand. I'll try to find some time to look into it again tomorrow - maybe we can crack it!

    cheers

    Garve
     
    Garve, Oct 26, 2006 IP
  4. Ronal

    Ronal Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello

    You can directly goto control panel settings in that click on
    1) click on IIS manager
    2) right click on defalut web site
    3) select new virtual directory
    4) browse and select the virtual directory
    5) browse and select the actula folder
    6) click on finish

    It creates virtual directory then check the url with local host....

    Hope u got it, if not search it in google

    Thanks
    KSoft
     
    Ronal, Oct 27, 2006 IP
  5. Garve

    Garve Peon

    Messages:
    62
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ronal - I think red_fiesta knows that - what he and I are looking for is a way to create virtual directories using ASP rather than through the Internet Services Manager.

    red_fiesta - I had a look at the Microsoft page - it says

    When you install Microsoft Windows NT Server version 4.0 and IIS, ADSI sample scripts and the WSH environment are installed by default.

    and

    When you install IIS, the sample IIS Admin Objects scripts are copied into the following directory by default:

    %windir%\System32\Inetsrv\AdminSamples.

    However, I can't find that directory on my server (Windows 2000 server) so I don't know whether the ADSI stuff has been installed.
     
    Garve, Oct 30, 2006 IP
  6. Garve

    Garve Peon

    Messages:
    62
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Garve, Oct 30, 2006 IP
  7. Garve

    Garve Peon

    Messages:
    62
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Garve, Oct 31, 2006 IP
  8. red_fiesta

    red_fiesta Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    thanks

    ill take a look
     
    red_fiesta, Oct 31, 2006 IP
  9. Garve

    Garve Peon

    Messages:
    62
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi again Red_fiesta - I've cracked it and am now able to set up virtual directories on my server using an ASP page! Your thread kicked me into gear on this again - I'm now in a position to let users create their own sites at the click of a button if I want to - haven't decided on that yet.

    cheers

    Garve
     
    Garve, Oct 31, 2006 IP
  10. red_fiesta

    red_fiesta Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    do you use any messanger service, would be interesting to share code

    thanks
     
    red_fiesta, Oct 31, 2006 IP
  11. Garve

    Garve Peon

    Messages:
    62
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Have sent you a PM

    cheers

    Garve
     
    Garve, Nov 1, 2006 IP
  12. Ender

    Ender Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hey
    I don't know if this topic is still hot but I have a question regarding this. I recently have been asked to create a virtual dir using ASP, now using the code here I get to the same error however the link provided by Garve tells me to create a user with a password... Sorry to say I'm not very good with ASP as of yet, but the way to add users is not going to work because I don't have any admin rights. Is there still a way to create a virtual directory (without admin right and no local IIS)? My PC is connected to a server from my work and also to the local network, which should have IIS on it but I dunno how to check it.

    Any help is appreciated ^^
     
    Ender, Nov 27, 2006 IP