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

本文共 1920 字,大约阅读时间需要 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;        }    }}

转载于:https://www.cnblogs.com/tommyli/archive/2013/06/08/3125747.html

你可能感兴趣的文章
ubuntu16.04降级内核版本至3.13.0-85
查看>>
Junit中的异常测试
查看>>
九度OJ 1038:Sum of Factorials(阶乘的和) (DP、递归)
查看>>
DRF之分页器组件
查看>>
mysql增删改查
查看>>
课程作业三
查看>>
JS中this的用法
查看>>
HW3.16
查看>>
最短路算法--转载---贝尔曼,迪杰斯特拉,弗洛伊德,很简单易懂,模板算是吧...
查看>>
猜数字游戏
查看>>
DELPHI XE Android 开发笔记
查看>>
用SquishIt最小化Css与Javascript文件
查看>>
调用WCF错误-There was no endpoint listening
查看>>
JS回调函数全解析教程
查看>>
定义未知成员和 Null 处理属性
查看>>
C++ string char[] 转化
查看>>
组件之间传值
查看>>
oracle 修改进程
查看>>
vue.js数据绑定
查看>>
PAT1013 Battle Over Cities
查看>>