ASP.NET Development Server .bat File

You want to start the ASP.NET Development Server from a .bat file. Some other guides are slightly confusing or incomplete. See screenshots and a list of steps to take. Here we see how you can use the development server in ASP.NET more easily.

This ASP.NET article explains the Development Server. It is based on Visual Studio 2008.

ASP.NET development server

Get started

Here we are starting with a Web Site project in Visual Studio 2008. Its location is the File System, and its language is Visual C#. When you are in Visual Studio and click the green arrow, the site should run correctly.

Create new .bat file. On your Windows desktop, right-click and select New -> Text Document. Rename the file so that its complete filename is "example.bat". This is a small program that we will use to start the ASP.NET Development Server.

Add code to .bat file. In the .bat file, you need to add two lines. The first line tells Visual Studio's environment to start up in the background. This line must contain the path to "vcvarsall.bat", which is in your Program Files directory. The second line invokes the WebDev.WebServer.exe application, and you can pass it the path to your web site's folder. In the following example, replace PATHSITE with the path to your web site folder.

call "C:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat"
"C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe"
    /port:3900 /path:"PATHSITE"

String description. The PATHSITE string is the path to your web site's folder, which contains your Default.aspx file, your App_Code folder, your App_Data folder, your Web.config, and other files. There is no actual EXE in this folder. My path is "C:\Users\Sam\Documents\Visual Studio 2008\WebSites\ExampleSite9".

Program icon (copyright Microsoft)

Double-click on the .bat file. Here we need to run the .bat file by clicking on it. After you do so, you will first see a command prompt window, which you can ignore. In the bottom corner of your screen, you will see the System Tray and a balloon pop up.

Right click and Open in Web Browser. Right click on the little page icon with the tiny gear and select Open in Web Browser. Your default web browser will open up and the Default.aspx page in your site will be executed.

Summary

ASP.NET web programming framework

Here we saw how you can invoke the ASP.NET Development Server from an icon on your desktop, or in a command prompt. This tip is available elsewhere but I struggled to make it work on my system, and this solution was adapted from them. It is useful because you can test your code without opening Visual Studio. You may have different data generated and you want to test it in the actual web site.

ASP.NET Tutorials
.NET