Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
184 views
in Technique[技术] by (71.8m points)

c# - How can I create a new application pool in a Web Setup Project?

I need to deploy my web service. It needs to run in a separate application pool in IIS with its own credentials.

Is it possible to do this by using a Web Setup Project in VS 2008?

By default, I seem to only be able to choose an existing application pool.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Check out this post http://forums.iis.net/t/1061734.aspx, it will give some rough idea about Microsoft.Web.Administration dll.

I have not studied the whole concept but I figured how to create new pool and how to attach with new web site / virtual directory.

Creating Application Pool

Microsoft.Web.Administration.ServerManager manager = new Microsoft.Web.Administration.ServerManager();
manager.ApplicationPools.Add("NewApplicationPool");
manager.CommitChanges();

Attaching with existing virtual directory

Microsoft.Web.Administration.ServerManager manager = new Microsoft.Web.Administration.ServerManager();
Site defaultSite = manager.Sites["Default Web Site"];

// defaultSite.Applications will give you the list of 'this' web site reference and all
// virtual directories inside it -- 0 index is web site itself.

Microsoft.Web.Administration.Application oVDir = defaultSite.Applications["/myApp"];            
oVDir.ApplicationPoolName = "NewApplicationPool";
manager.CommitChanges();

This way you can assign application pool to your new website using the custom actions, overriding the commit method of installer class.

If still find yourself struggling, please let me know and I'll try to send the code.

Regards Faiyaz [email protected]


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...