Introduction:
Here I will explain how to check whether IIS manger running or not in c#, vb.net using asp.net. We can check whether IIS manager running or not using ServiceController in c#, vb.net using asp.net.
Description:
In previous articles I explained install iis manger in windows, IIS cannot open w3svc service on computer, host website in IIS with custom url in asp.net, get values from ienumerable list in c#, vb.net, convert datatable to generic list using LINQ and many articles relating to asp.net, c#, vb.net, jQuery and JavaScript and. Now I will explain how to check whether IIS manager running or not in c#, vb.net using asp.net.
In previous articles I explained install iis manger in windows, IIS cannot open w3svc service on computer, host website in IIS with custom url in asp.net, get values from ienumerable list in c#, vb.net, convert datatable to generic list using LINQ and many articles relating to asp.net, c#, vb.net, jQuery and JavaScript and. Now I will explain how to check whether IIS manager running or not in c#, vb.net using asp.net.
If you want to check IIS running or not we need to
write the code like as shown below
C#
Code
protected void btnClick_Click(object
sender, EventArgs e)
{
ServiceController controller
= new ServiceController("W3SVC");
lblStatus.Text = controller.Status.ToString();
}
|
VB.NET
Code
Protected Sub
btnClick_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim controller As New ServiceController("W3SVC")
lblStatus.Text
= controller.Status.ToString()
End Sub
|
If you want to see it in complete example open your
Default.aspx page and write the code like as shown below
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Check IIS Running
Status in Asp.net</title>
</head>
<body>
<form id="form1"
runat="server">
<div>
<asp:Button ID="btnClick"
runat="server"
Text="Check
Status"
onclick="btnClick_Click" />
<asp:Label ID="lblStatus"
runat="server"></asp:Label>
</div>
</form>
</body>
</html>
|
Now we need
to add System.ServiceProcess reference to our application for that right click on
your application à select Add Reference à select System.ServiceProcess like as shown below
Now open your code behind file and add following
namespaces
C#
Code
using System;
using System.ServiceProcess;
|
VB.NET
Code
Imports System.ServiceProcess
|
Now write the following code in code behind to check
the status of IIS manager
C#
Code
|
VB.NET
Code
|
Demo
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
2 comments :
Hi Sir,
Good article and very helpful, by this i can find out idle time of application cause many time application stop work after some time idle state.
Hi Sir,
Good article and very helpful, by this i can find out idle time of application cause many time application stop work after some time idle state.
Note: Only a member of this blog may post a comment.