Thursday, September 09, 2010

How to restart a asp.net web application using button click

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <script runat="server">
        protected void Stop(object sender, EventArgs e)
        {
            bool error = false;
            try
            {
                HttpRuntime.UnloadAppDomain();
            }
            catch
            {
                error = true;
            }
            if (!error) return;
            string ConfigPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "\\web.config");
            try
            {
                File.SetLastWriteTimeUtc(ConfigPath, DateTime.UtcNow);
            }
            catch
            {
                //
                // Cant shut down
                //
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button runat="server" ID="btnStop" OnClick="Stop" Text="Stop" />
    </div>
    </form>
</body>
</html>

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...