# Monday, 03 January 2011

As (web)developer mainly living inside Visual Studio during the day at work I usually make use of the built in webserver of this IDE, namely Cassini. However when I close the debugging session one or more instances, especially more when I’m inside one of my test projects, keep on running. I don’t like to stop them all one by one so I created a simple file with notepad and saved it as KillAllRunningCassinis.bat. For people old enough to remember, .bat files were much used in MS-DOS but still can be used in Windows.

The content of this simple file is:

taskkill /im webdev.webserver.exe

Taskkill is a handy tool to instantly kill processes on your Windows machine. To read more about it take a look at the Technet documentation.

Grz, Kris.

Monday, 03 January 2011 21:42:53 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, 29 October 2006

The freely available tool WebMatrix, which I used on my old pc to develop ASP.NET pages several years ago, came with a built in webserver, code named Cassini, so a developer could test his/her pages on the localhost.

With the .NET 2.0 framework this localhost only webserver's shipped and if you don't have Visual Studio 2005, or the free Visual Web Developer Express Edition tool (which is the follow up of WebMatrix), you can still execute your pages and view the outcome in a browser.

Here's a little guide on how to proceed:

Create a folder on your hard drive. In this example I created c:\MyASPNETPages\ where my testpage will reside. The testpage itself contains this code:

    1 <%@ Page Language="C#" %>

    2 

    3 <script runat="server">

    4 

    5     protected void Page_Load(object sender, EventArgs e)

    6     {

    7         Label1.Text = DateTime.Now.ToShortDateString();

    8     }

    9 

   10 </script>

   11 

   12 <html>

   13 <head runat="server">

   14     <title>Test Page</title>

   15 </head>

   16 <body>

   17     <form id="form1" runat="server">

   18     <div>

   19         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

   20     </div>

   21     </form>

   22 </body>

   23 </html>

Now start up a DOS box (Start | Run, type in cmd followed by enter). Navigate to the folder C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

If you don't know how to do this you can type in the following in the opened DOS box:
cd \windows\microsoft.net\framework\v2.0.50727

After that you can type in the text in bold:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>webdev.webserver /port:8088 /path:
"c:\MyASPNETPages" /vpath:"/Test"

Ok what does this mean?

webdev.webserver is the executable itself with the following arguments: port, path and vpath. Port and vpath are optional parameters. After typing the previous lines in bold in and pressing enter a webserver starts up (Figure 1):


Figure 1: Started up webserver

From Figure 1 we can also see what our url will look like (http://localhost:8088/Test).
This demonstrates the purpose of the port and vpath arguments. Port is the port number on which the server will listen. The default is 80 but if you have IIS running, like me, it's better to use another number or they will conflict.

 

After starting the webserver I can easily navigate to my webpage by typing in the url in the address bar of my browser: http://localhost:8088/Test/

As you would've expected I get to see the current date displayed in my page.

If I ommit the vpath argument it would default to "/", meaning that I can navigate to my pages by just typing in this in the address bar: http://localhost:8088/test.aspx

Grz, Kris.

Sunday, 29 October 2006 13:05:19 (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |