简体   繁体   English

在 IIS 中更新 Web 应用程序 - 最佳实践

[英]Updating a Web Application in IIS - Best practices

What are the best practices for updating a web application in IIS?在 IIS 中更新 web 应用程序的最佳实践是什么?

The first page you see when you visit our application is a login page.当您访问我们的应用程序时,您看到的第一页是登录页面。

What I want to achieve is that visitors be redirected to a page stating that the application is being updated.我想要实现的是将访问者重定向到说明应用程序正在更新的页面。 And for users with an admin role being able to login successfully (to check whether everything is working properly)对于具有管理员角色的用户能够成功登录(检查一切是否正常)

In web.config we keep track of wheter the application is being updated (updating = [true|false] and then on the authentication_event:在 web.config 中,我们跟踪应用程序是否正在更新(更新 = [true|false],然后在 authentication_event 上:

if (updating) 
{

   if (User.IsInRole("admin"))

   {

      redirect to main web app...

   }
   else
   {     

     redirect to web being updated page....

   }

}
else 
{

   redirect to main web app..

}

Any advise will be appreciated immensely..任何建议将不胜感激..

I test everything locally, then I use the built in app_offline.html file on production server.我在本地测试所有内容,然后在生产服务器上使用内置的 app_offline.html 文件。 When this file is present it will be served to clients, in meantime I am uploading new content.当此文件存在时,它将提供给客户,同时我正在上传新内容。 When done, renaming app_offline.html to something different and the new app starts.完成后,将 app_offline.html 重命名为不同的名称,新的应用程序就会启动。

Looks like you pretty much have it figured out.看来你已经想通了。

if (WebConfigurationManager.AppSettings["updating"]=="true") 
   if (User.IsInRole("admin"))
       Response.Redirect("~/Main.aspx");
   else
       Response.Redirect("~/Updating.aspx");
else
   Response.Redirect("~/Main.aspx");

instead of doing it via web.config, you should be saving the updating flag in some other xml file or database, as each time you update your web.config file, your application restarts, thus invalidating current application variables, caches, etc etc而不是通过 web.config 执行此操作,您应该将更新标志保存在其他一些 xml 文件或数据库中,因为每次更新 web 等无效的当前应用程序配置文件,因此缓存等

apart from that, you got the other logic right.除此之外,您的其他逻辑是正确的。 but avoid touching the web.config as far as possible - i personally only save the connection string in the web.config as that hardly changes但尽量避免触摸 web.config - 我个人只将连接字符串保存在 web.config 中,因为它几乎不会改变

but rest of the key value pairs which change often, i have them saved in sql database table.但是经常更改的键值对的 rest,我将它们保存在 sql 数据库表中。 so that way i never ever have to do an application restart unless my connection string changes:-)因此,除非我的连接字符串发生变化,否则我永远不必重新启动应用程序:-)

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

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