Programmatic Site "Reset"

Discussion in 'ASP .Net' started by Guest, Jun 20, 2006.

  1. Guest

    Guest Guest

    Hi. Is there a way to make a call in ASP.NET that will effectively do exactly
    the same thing is when you "touch"/change the web.config file? In other
    words, I want to be able to programmatically cause the same kind of general
    resetting that happens when you touch the web.config file.

    Alex
     
    Guest, Jun 20, 2006
    #1
    1. Advertisements

  2. Touching global.asax will do an application restart,
    and calling appdomain.unload will do it, too.

    iisreset resets the whole IIS server.

    You can also restart individual application pools.
     
    Juan T. Llibre, Jun 20, 2006
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Guest, Jun 20, 2006
    #3
  4. That's a great tip, Peter...

    For VB fans...here's the equivalent VB.NET code :

    Private Sub KillAspNetProcess()
    Dim processName As String = "aspnet_wp"
    Dim os As System.OperatingSystem = System.Environment.OSVersion
    'Longhorn and Windows Server 2003 use w3wp.exe
    If (((os.Version.Major = 5) AndAlso (os.Version.Minor > 1)) OrElse (os.Version.Major = 6)) Then
    processName = "w3wp"
    End If
    For Each process As Process In Process.GetProcessesByName(processName)
    Response.Write(("Killing ASP.NET worker process (Process ID:" + (process.Id + ")")))
    process.Kill
    Next
    End Sub
     
    Juan T. Llibre, Jun 20, 2006
    #4
  5. Guest

    Guest Guest

    Guest, Jun 20, 2006
    #5
  6. Laurent Bugnion, Jun 21, 2006
    #6
  7. Guest

    MrTommm

    Joined:
    Mar 22, 2012
    Messages:
    1
    Likes Received:
    0
    C# TouchWebConfig method

    public void TouchWebConfig()
    {
    string sWebConfigPath = HttpContext.Current.Server.MapPath("~/Web.Config");
    System.IO.File.SetLastWriteTimeUtc(sWebConfigPath, DateTime.UtcNow);
    }
     
    MrTommm, Mar 22, 2012
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.