Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 25th, 2006, 06:39 PM
Authorized User
Join Date: Oct 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Default Web Site : Virtual Directory

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

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>"
end if

' Second, Create the virtual directory (Vdir) path
Set VdirObj = ServObj.Create("IIsWebVirtualDir", "MyVdir")
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 &

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)

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

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

Old October 26th, 2006, 12:39 AM
Friend of Wrox
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post

Hey Friend

I guess this is asp.net forums, u can post this to the asp section for better results.

Old October 26th, 2006, 08:00 AM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

I responded to this here:


I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature

Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Directory MeenaG BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 1 December 2nd, 2006 01:48 PM
Change the IIS Web Site Default Directory using C# DudeBori82 C# 0 May 23rd, 2005 08:51 AM
Virtual Directory kristina BOOK: Beginning ASP 3.0 1 April 22nd, 2005 09:49 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.