Hi, in my previous atrlicle I show how to create virtual directory. Here I have attched the code for creating , deleteing or listing virtual directories or website in IIS using ASP.NET and C#.
Code uses DirectoryService name space which allows access to Internet Information Services (IIS). The System.DirectoryServices namespace also provides access to the Active Directory. The classes in this namespace can be used with any of the Active Directory service providers including Internet Information Services (IIS), the Lightweight Directory Access Protocol (LDAP), the Novell Directory Services in NetWare (NDS), and WinNT.
Following softeares are required for this project to run successfully.
* IIS 5.1 or later version
* Dotnet SDK 2.0
* Admin access to server on which IIS in installed
You can download the Source Code here. Once you download the file pls change the extension from “doc” to “zip”. Sorry for uploading the code this way. I do not found any option to upload zip file. 🙂
Happy Programming !!
great. It is what i am looking for.
igor,
Thanks for your precious comment.
Thank you very much, your code is very helpful!
hi frnd
I have one doubt,that is i have one web application with ftwo aspx page and it code behind file in c# with msacess database in App_Data folder for insert some record and displaying it ti datagrid in first aspx pageIn second page i am insert some record in the datbase specified app_data folder.Then make websetup for this web aplication and build and install,websetup name is webapp
Now i run firstpage http://localhost/webapp/first.aspx here i am displaying record in the table and second page i going to insert some data to the table.when press insert button the record will be insert into database specifed in webapp/App_data/dbase.mdb.but i cant insert record into the table throu my webapp site created by websetup,not only i can’t handle file copy and write also.
if know tell me.one more thing is after i give the write permission for this folder by IIS permission wizard,it will work fine,but i not going to do,setup will takecare
by hajaworld@yahoo.co.in
Hi,
I am not able to get all the virtual directories in IIS. I gave my computer name as server and left directory name blank. It gave me only one result. Am I making mistake in entering details or else what should I enter to get a list of all virtual directories??
Thanks,
Nikhil
hi,
can you provide the same application as a windows application and not as a web application.
thanks,
kunjal
Dude?! What? Are you afraid to type something in for yourself?
Try writing some code on your own for a change man.
The guy gave you the classes and the code. All you have to do is slap together a UI.
Lazy paracodisite.
Kujal,
I have to search that if I have it or not. As you know its Diwali time I will search for code in next week and let you know.
Hi,
The code is good, but there was an issue when creating virtual directory.
Actually, the Virtual Directories are created under the root diretory of the referenced website/parentdirectory.
So in the line, where we are building the “strIISPath” for the Virtual Directory, we need to give the path as “/ROOT” also, to make the directory visible in an IIS6.0. This is the way it worked for me. Same way, we need to modify the code for the DeleteVirtualDirectory.
Found a bug to createVirtualDirectory
public static bool CreateVirtualDirectory(WebSiteInfo WebSiteInformation,IISVirsion IISVersionNumber)
{
// Check for valid path
if (IsExist(strIISPath))
{
strIISPath += “/root”; //Line to add if not you can’t see the virtual directory in IIS
Hi, can you help me with this problem? I need to create new webSite under IIS5.
Your source code uses “CreateNewSite” method, whis is available from IIS6 and later.
So, what can I use under IIS5?
Thanks!
I really like your material.
A+ Outstanding!
Is there any way to create/configure an asp.net application from a web app?
Marico Coelho,
Thanks.
svelasquez,
Can you please explain your question in more descriptive manner?
Franta,
You can not create new website in IIS 5. Website is introduced in IIS 6 and later version. You can only create virtual directory in IIS 5.
Chiragrdarji,
After I create a virtual directory or website, to prepare it to run .net code, it has to be converted to an application. It is during this process that you specify what Application Pool to use.
I checked out the IISHelper method you are using to create the website, but I don’t see anything that will convert it to an application once the site has been created.
Any idea how this is done or if it is even possible?
Thanks.
nairik pointed out a bug. Is that bug valid and if so where does that line go? Before the if exists or after. Seems like before, but does it go before creating the rest of the string or at the end? Seems like the whole function wouldn’t work if it was a problem. Also, after changing the string, do I need to change it back so that the string is the same as it is now because it seems its creating the sites correctly, except for a litte problem I had when putting in http://www.website.com it ended up as http://www.wwww.website.com.com in the binding information but it was correct in the list.
I really like your post.
I thank you for it.
hello,
i want to give read, write, directory browsing permissions to a virtual directory which is already present in IIS. how to do that?
Thanks a lot for this article:)
Hai,
I have to created website IIS 6.0 . But how can we provide directory security option in vb.net . For how to automatically check the annonymous access in IIS 6.0
A very helpful post!!
Is there any way to get information about each website status in IIS ( not IIS status) ?
e.g. is it running or stopped?
thanks
Hi
I just download your code.
Thanks
how to set startup page in iis using same code pls reply
how to set user friendly name to virtual directory. pls reply
Hi there,
I really like your script, nice job ;o)
But is there a way to set the asp.net version and the application pool when i create a website ?
hi its really good and worthable
Hi Dear,
Could you please help me.
Actually i have designed a web page in ASP.NET 2.0, now i want to run it on internet. I have published it, It is working properly on local host. I have uploaded it on Internet through FTP.
On my web page i have a button, at the click of this button when i call this my web page its shows the following error.
This is a marker file generated by the precompilation tool, and should not be deleted!
please send my solution at
please_inform@yahoo.com
Please help me out ! its very urgent
I will be highly obliged
Thanks & Regards
Hi Dear,
is any one here to help me out!!!!!!
please send my solution at
please_inform@yahoo.com
Please help me out ! its very urgent
I will be highly obliged
Thanks & Regards
Very helpful article.
Gr8…
I want to know how to check is IIS installed or not using .net?
Hi chiragrdarji,
When i use AddValueToHostHeader(..) to append an hostheader in the currently website then error:
System.ArgumentNullException: Value cannot be null. Parameter name: value at System.Web.Caching.CacheEntry…
But in other website then it runs very well. Why is it that? Please help me.
Hi,
Fantastic Code. Works great apart from it doesnt set up the website permissions.
So the Virtual Directory is there but no one can access it or alter it.
Have i done something wrong?
Hi,
Do you have any options in IIS, by removing the Virtual directory it removes the Physical path?
Thanks in Advance
Solanki
Да уж, автор сайта действительно очень добрый и отзывчивый человек. Спасибо 🙂
Wah !
Good Work
Thanks
how to convert (moveing) form virtual directory to websites in iis server 6?
thanks a lot.
i hav net of 1.1 and 2.0 i tried creating vdir but when i run my aspx files is says unhandled exemption an failed to access meta file (sort of that ) now i wil try that of your file i c the results n get back to u
Thanks for this code!
Hi ,
I had a requirement of giving the permissions to the published websites in c#. Like give admin permissions, etc.
Can you help me out.
Thanks & Regards
srinivas
Интересно, хотя с опечатками посты пишете
здесь видел ет gamebulletin.ru
it’s nice piece of code i got. This is exactly wat i was looking for. Thanks a lot.
i am trying to make some changes using this as base like edit properties of virtual directory and remotely create virtual directory etc.
I just wanted to know which part of the code u r checking for authentication in this code and how?
Any help would be appreciated.
Thanks a lot in advance.
-shwetha
Hi, is theere any options in IIS, by removing the Virtual directory it removes the Physical path?
appreciate the time
Awesome job, this is exactly what I was looking for.
Great post.
hi i have some problem about this code if you can help me , it would be great of you ,
public static int CreateWebsite(string webserver, string serverComment, string serverBindings, string homeDirectory)
{
DirectoryEntry w3svc = new DirectoryEntry(“IIS://88.208.234.31/w3svc”);
//Create a website object array
object[] newsite = new object[]{serverComment, new object[]{serverBindings}, homeDirectory};
//invoke IIsWebService.CreateNewSite
object websiteId = (object)w3svc.Invoke(“CreateNewSite”, newsite);
return (int)websiteId;
}
public static void Main(string[] args)
{
int a = CreateWebsite(“88.208.234.31”, “Testing.com”, “:80:Testing.com”, “C:\\inetpub\\wwwroot”);
Console.WriteLine(“Created website with ID: ” + a);
}
it passes me some wiried exeption :
“Unknown error (0x80005000)”
with pointing to this line of code :
object websiteId = (object)w3svc.Invoke(“CreateNewSite”, newsite);
hi nariman mohammed,
I am getting the same problem please help me for this is you have solution for this.
Comfortabl y, the post is actually the greatest on this worthy topic. I agree with your conclusions and will eagerly look forward to your next updates. Just saying thanks will not just be adequate, for the tremendous clarity in your writing. I will immediately grab your rss feed to stay abreast of any updates. Pleasant work and much success in your business dealings!
I admit, I have not been on this webpage in a long time… however it was another joy to see It is such an important topic and ignored by so many, even professionals. I thank you to help making people more aware of possible issues.Great stuff as usual
asmgermany stellt Metallbuchstaben wie Edelstahlbuchstaben, Messingbuchstaben, Aluminiumbuchstaben, Bronzebuchstaben
[…] that mange An IIS Virtual paths or application a very Good Reference will be at that link Mange IIS Categories: SharePoint Tags: Asp Comments (0) Trackbacks (0) Leave a comment […]
Find this blog great. Hope to see it further when i have more time. If your looking for a job, visit our site.Thanks
I couldn’t agree more…thanks for your post.
Hi,
Thanks a Lot for this code, I am looking for the same code to implement in Custom action in the Web Setup Project.
I leave here some useful features to manage IIS
http://bloguernauta.blogspot.com/2010/03/some-functions-in-c-to-manage-iis.html
Why do the guys in the picture have band-aids on their fingers? From all the hard-core coding??
Hi…
I am new to VB.net.
Can anyone tell me how to import the following packages to create website or Virtual Directory in IIS7
System.DirectoryServices
or
Microsoft.Web.Administration
OR
Is there any other way to create IIS website.
I mean, do i have to add any references?
The code is good and its working to get the information realted websites inside virtual directory but i want the site information inside the WebSite directory of IIS. Please some one give me the solution. Thanks in advance.
BUT IS THERE A CODE TO FIND THE PHYSICAL PATH OF WEBSITES THAT ARE CREATED OUTSIDE VIRTUAL PATH , DIECTLY UNDER WEBSITE FOLDER
i have too have a same problem
Thanks for the examples! It saved me at least a day and a half of coding.
Really good examples and code!
Hi friends, its great post about tutoringand entirely defined, keep it up all the time.
Thanks for the code.
But, I am getting root directories only but not sub directories & files from all directories. Also I want file structure in a tree view from IIS site. So is it possible to get file structure by providing web URL only.
Please help me out if possible.
Thank you in advance…
Howdy are using WordPress for your blog platform? I’m new to the blog world but I’m
trying to get started and create my own. Do you need
any html coding knowledge to make your own blog?
Any help would be really appreciated!
Вероятности плавления активной зоны домен