简体   繁体   English

以编程方式将Web应用程序导入IIS

[英]Import a web application to IIS programmatically

I have a C# web application developed and web deploy ready - meaning I have the WebApp.Web.zip file ready. 我已经开发了一个C#Web应用程序并且可以进行Web部署-这意味着我已经准备好了WebApp.Web.zip文件。 I have verified that manual import of this application in my IIS 7.0 manager works and I am able to run the application in the browser. 我已经验证可以在IIS 7.0管理器中手动导入此应用程序,并且可以在浏览器中运行该应用程序。

Open IIS Manager (cmd->inetmgr), and explore the "Sites -> Default Web Site", and click on "Import Application" on the Right menu under Deploy. 打开IIS管理器(cmd-> inetmgr),浏览“站点->默认网站”,然后在“部署”下的右键菜单上单击“导入应用程序”。 Browse to the path of the AAA.Web.zip and click "open". 浏览到AAA.Web.zip的路径,然后单击“打开”。 Go through the Package Import wizard. 经历软件包导入向导。 Click on "Browse *:80". 单击“浏览*:80”。

I now want to programmatically do the import of this application in the local IIS Server. 我现在想以编程方式在本地IIS服务器中导入此应用程序。 Could you help me with some pointers? 您能帮我一些指点吗?

So If all that you want is to host your WebApplication in IIS, and you don't want to do it all the way manually. 因此,如果您想要的只是将WebApplication托管在IIS中,并且您不想一路手动进行。

There is a neat way to do so, 有一种整齐的方法,

Create a WebSetup Project. 创建一个WebSetup项目。 ie Add a New Project into the Solution of your Existing WebApplication ie inside visual studio, Add New Project, go to 将新项目添加到现有WebApplication的解决方案中,即在Visual Studio中,添加新项目,转到

Other Project Types >> Setup And Deployment >> Visual Studio Installer >> Web Setup Project Other Project Types >> Setup And Deployment >> Visual Studio Installer >> Web Setup Project

Just add Primary Output and Content Files of your WebApplication to the Setup Project and you are done. 只需将WebApplication的Primary OutputContent Files添加到安装项目中即可。 All you have to do is to build your solution. 您要做的就是构建您的解决方案。

And inside the bin folder of your Setup Project, you will get an .exe , which upon installation, hosts the WebApplication in IIS. 在Setup Project的bin文件夹中,您将获得一个.exe ,安装后,它将在IIS中托管WebApplication。

see more about creating a setup Project in visual studio 了解有关在Visual Studio中创建安装项目的更多信息

atleast it is cleaner than WebDeploy Command Line Syntax 它至少比WebDeploy命令行语法更干净

Just use the webdeploy command line in your buildscript or from a Process object 只需在您的构建脚本中或通过Process对象使用webdeploy命令行

http://technet.microsoft.com/en-us/library/dd569106(v=ws.10).aspx http://technet.microsoft.com/en-us/library/dd569106(v=ws.10).aspx

Microsoft basically doesn't let you hook in with an API, there are a few ways to hack through it, but honestly you'll be better off using the command line 微软基本上不允许您使用API​​,有几种方法可以破解它,但老实说,使用命令行会更好

see this old answer 看到这个老答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM