简体   繁体   English

如何部署/发布ASP.NET网站?

[英]How to Deploy/Publish an ASP.NET website?

Is there any easy way to Deploy/Publish a website written in asp.net ? 有没有简单的方法来部署/发布用asp.net编写的网站? And what is the difference between deploy and publish ? 部署和发布有什么区别?

Here is a site that shows different techniques how to accomplish this task. 这是一个网站,显示了如何完成此任务的不同技术。 There are many techniques that can be utilized as a deployment strategy for your web application.: 有许多技术可用作Web应用程序的部署策略:

Beansoftware How to Deploy ASP.NET Web Application Beansoftware如何部署ASP.NET Web应用程序

Alt + B + H combination (opens publish window for ASP.NET web site / application) is the most simple way to deploy an application to the required location. Alt + B + H组合(打开ASP.NET网站/应用程序的发布窗口)是将应用程序部署到所需位置的最简单方法。

Publish used for compiling and deploying application to server. 发布用于编译和部署应用程序到服务器。

Well, it depends on what you're trying to accomplish from an uptime/availability point of view. 嗯,这取决于您从正常运行时间/可用性的角度来看要实现的目标。 The publish/xcopy/installer options are interesting but all neglect to address the issue that it takes time for those options to complete. publish / xcopy / installer选项很有意思,但都忽略了解决这些选项需要时间才能完成的问题。 From the time the first file is copied into the directory to the time the last file is copied in the site is in an inconsistent state. 从第一个文件复制到目录到最后一个文件在站点中复制的时间处于不一致状态。

The ASPX files may refer to data-layer objects that aren't in the bin directory yet, or the bin directory may have a DLL w/a changed set of params on a function, but the aspx hasn't been installed yet, so the aspx is still looking for the old function. ASPX文件可能引用不在bin目录中的数据层对象,或者bin目录可能在函数上有一个带有更改的params集的DLL,但是aspx尚未安装,所以aspx仍在寻找旧功能。 In short because the deployment isn't an atomic process you can/will have problems. 简而言之,因为部署不是原子过程,您可能/将会遇到问题。

We've addressed this issue by installing the new files to a new directory, and then going into IIS and changing the website to point to the new directory. 我们通过将新文件安装到新目录,然后进入IIS并将网站更改为指向新目录来解决此问题。 This makes the change an atomic process and makes things much smoother. 这使得更改成为原子过程并使事情变得更加顺畅。 Is it perfect? 它完美吗? Nope. 不。 You can have viewstate issues or session issues (session is preserved, but maybe the new code looks for something in session that the old code didn't set) but it still makes the process much smoother. 您可以拥有viewstate问题或会话问题(会话被保留,但是新代码可能会查找旧代码未设置的会话中的内容),但它仍然使流程更加顺畅。

Of course none of these solutions address the other non-atomic part of upgrading the website... the database. 当然,这些解决方案都没有涉及升级网站......数据库的其他非原子部分。 Again, the process of changing the DB schema takes time. 同样,更改数据库架构的过程需要时间。 Do you upgrade the code first or the database first? 您是先升级代码还是先升级数据库? Can the DB change work w/out the code change (a new column that supports null or has a default) or can the code change work w/out the DB change (removing a column)? DB更改是否可以更改代码更改(支持null或具有默认值的新列),或者代码更改是否可以更改数据库更改(删除列)? That's a case-by-case analysis, and isn't addressed by any of these solutions 这是一个案例分析,并未通过任何这些解决方案解决

Of course, if you can kick your users off the site for a period of time then life is easier, but if you're trying to achieve 100% uptime then it's not so simple. 当然,如果你可以让你的用户离开网站一段时间,那么生活会更容易,但如果你想要实现100%的正常运行时间,那就不那么简单了。

Sometimes it's not practical to set up Web Publish to your desired target. 有时,将Web Publish设置为所需目标是不切实际的。 If that's the case you might still be able to publish to your local machine (as outlined below) and then XCOPY deploy to your target. 如果是这种情况,您仍然可以发布到本地计算机(如下所述),然后XCOPY部署到您的目标。

  1. In IIS right-click Sites and click Add Website 在IIS中,右键单击“站点”,然后单击“添加网站
  2. Set up a new web site as shown and click OK 如图所示设置新网站,然后单击“确定” 在此输入图像描述
  3. In Visual Studio (running with administrator privilege), right-click your ASP.NET web project, select Publish... 在Visual Studio(以管理员权限运行)中,右键单击ASP.NET Web项目,选择“发布”...
  4. Click the Profile heading and from the drop-down select New Custom Profile... 单击配置文件标题,然后从下拉列表中选择新建自定义配置文件...
  5. Enter a profile name like "localhost44321", set up the profile as shown and click Publish 输入配置文件名称,如“localhost44321”,如图所示设置配置文件,然后单击“发布” 在此输入图像描述

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

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