博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何重启IIS进程
阅读量:6291 次
发布时间:2019-06-22

本文共 1852 字,大约阅读时间需要 6 分钟。

namespace Utilities.General{    public static class Utility    {        public static bool RestartAppPool()        {            //First try killing your worker process            try            {                //Get the current process                Process process = Process.GetCurrentProcess();                // Kill the current process                process.Kill();                // if your application have no rights issue then it will restart your app pool                return true;            }            catch (Exception ex)            {                //if exception occoured then log exception                Logger.Log("Restart Request Failed. Exception details :-" + ex);            }             //Try unloading appdomain            try            {                //note that UnloadAppDomain requires full trust                HttpRuntime.UnloadAppDomain();                return true;            }            catch (Exception ex)            {                //if exception occoured then log exception                Logger.Log("Restart Request Failed. Exception details :-" + ex);            }             //Finally automating the dirtiest way to restart your application pool             //get the path of web.config            string webConfigPath= HttpContext.Current.Request.PhysicalApplicationPath + "\\web.config";            try            {                //Change the last modified time and it will restart pool                File.SetLastWriteTimeUtc(webConfigPath, DateTime.UtcNow);                return true;            }            catch (Exception ex)            {                //if exception occoured then log exception                Logger.Log("Restart Request Failed. Exception details :-" + ex);            }             //Still no hope, you have to do something else.            return false;        }    }}

转载地址:http://lscta.baihongyu.com/

你可能感兴趣的文章
jdk6.0 + Tomcat6.0的简单jsp,Servlet,javabean的调试
查看>>
Android:apk签名
查看>>
2(2).选择排序_冒泡(双向循环链表)
查看>>
MySQL 索引 BST树、B树、B+树、B*树
查看>>
微信支付
查看>>
CodeBlocks中的OpenGL
查看>>
短址(short URL)
查看>>
第十三章 RememberMe——《跟我学Shiro》
查看>>
mysql 时间函数 时间戳转为日期
查看>>
索引失效 ORA-01502
查看>>
Oracle取月份,不带前面的0
查看>>
Linux Network Device Name issue
查看>>
IP地址的划分实例解答
查看>>
如何查看Linux命令源码
查看>>
运维基础命令
查看>>
入门到进阶React
查看>>
SVN 命令笔记
查看>>
检验手机号码
查看>>
重叠(Overlapped)IO模型
查看>>
Git使用教程
查看>>