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:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...