将新的 DLL 发布/上传到 IIS:上传时网站关闭 [英] Publishing/uploading new DLL to IIS: website goes down whilst uploading

查看:24
本文介绍了将新的 DLL 发布/上传到 IIS:上传时网站关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当为大型 Web 应用程序(dll 大约 1mb)上传新的 DLL 时,IIS 会抛出错误,因为 DLL 处于使用中",这意味着在上传 DLL 时网站已关闭.有没有办法阻止这种行为?

When uploading a new DLL for a large web application (dll is around 1mb) IIS throws an error because the DLL is 'in-use', meaning the website is down while the DLL is being uploaded. Is there a way to stop this behaviour?

此外,尽管我使用的是 Web 应用程序,而不是网站,但每当我上传新的 DLL 时,IIS 在全新上传后仍需要一段时间才能重新启动.我以为这种等待通常只针对网站,因为它们需要由 IIS 编译,而不是 Web 应用程序?

Also, although I am using Web Applications, not Web Sites, whenever I upload a new DLL it still takes a while for IIS to restart after a fresh upload. I thought this wait was generally only for websites as they need to be compiled by IIS, not Web Applications?

推荐答案

一旦您做出这样的更改,您就已经有效地更改了依赖项.该站点需要在 ASP.NET 的卷影副本文件夹中重新编译.

As soon as you make a change such as this you've effectively changed a dependency. The site will need to be recompiled in ASP.NET's shadow copy folders.

更新:

根据您的评论:如果有人在电子商务网站上购买商品并同时推出新的更新怎么办?它是我的 .NET 漏洞之一(我对 php 怀念的一件事是轻松上传 PHP 文件而没有麻烦)

如果您只有一台服务器,那么您需要计划更新并预先警告该站点将因升级而无法使用.ASP.NET 中有一个名为 App_Offline.htm 的功能.这是一个特殊的页面,当出现在您的应用程序中时,无论请求哪个页面,它都会导致 ASP.NET 呈现其内容.您可以使用它来显示一条消息,向用户解释该站点处于脱机状态以进行维护.您可以在此处访问 Scott Guthrie 的博客阅读更多相关信息.

If you've only got a single server then you need to plan your updates and give some advance warning that the site will be unavailable due to an upgrade. There's a feature in ASP.NET called App_Offline.htm. It's a special page which when present in your application will cause ASP.NET to render its contents no matter which page is requested. You can use this to display a message explaining to users that the site is offline for maintenance. You can read more about it here on Scott Guthrie's blog.

以这种方式进行站点升级并非没有道理,因为它是一种在单个原子步骤中执行站点更新的机制,并且如果您向用户提供大量他们不会介意的预先警告(并且可能在您流量处于典型的低点).

It's not unreasonable to approach site upgrades this way because it's a mechanism to perform a site update in a single atomic step and provided you give users plenty of advance warning they won't mind (and perhaps do this at a time when your traffic is at a typical low point) .

你提到在 PHP 中你不会有这个问题.实际上,如果您要更新的不仅仅是几个不相关的页面,那么您应该在升级过程中阻止用户访问该站点,这是理所当然的.

You mention that in PHP you wouldn't have this problem. Actually, if you're updating anything more that a couple of non-related pages then you should be preventing users from accessing the site during upgrades as a matter course.

假设您要更新五六页都松散相关的页面 - 也许作为电子商务应用程序的一部分.在上传过程中,您部署第一个页面并将其提供给用户.您对此页面所做的更改之一是向表单添加一个新字段.该页面回发到另一个使用此字段的 PHP 脚本.存在两种情况:

Say you're updating five or six pages all loosely related - perhaps as part of an e-commerce application. During the upload process you deploy the first page and it gets served to a user. One of the changes you made to this page was to add a a new field to a form. The page posts back to a another PHP script that uses this field. Two scenarios exist:

  1. 回发页面是新页面,仍在您的上传队列中.这会破坏新上传的脚本,因为当用户点击提交时,没有任何东西可以提交.

  1. The postback page is new and is still in your upload queue. This breaks the newly uploaded script because when a user clicks submit there is nothing to submit to.

回发页面已存在但尚未更新.此页面将表单发布字段写入数据库.您已将此新字段添加到数据库中,但它是必填字段且不能为空.您尚未更新的回发脚本尝试更新数据库,但引发错误,因为新字段不在回发表单的 INSERT 语句中,因此为空,导致 NOT NULL 约束冲突.

The postback page already exists but hasn't been updated. This page writes the form post fields to a database. You've added this new field to the database but it's a mandatory field and can't be null. Your no-yet-updated postback script tries to update the DB but an error is raised because the new field isn't in the postback form's INSERT statement and thus is null causing a NOT NULL constraint violation.

我可以继续.如果您的站点提供的不仅仅是一些微不足道的功能,那么您应该离线进行所有更新,以确保您更新的所有代码都部署在单个原子更新中.

I could go on. If your site provides more than just a trivial amount of functionality then you should go offline for ALL updates to ensure that ALL you're updated code is deployed in a single atomic update.

这篇关于将新的 DLL 发布/上传到 IIS:上传时网站关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆