Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Developing ASP.NET applications without VS.NET

0.00/5 (No votes)
22 Aug 2003 1  
This article will explain how to create and develop ASP.NET applications without using VS.NET.

Introduction

This article will explain how to create and develop ASP.NET applications without using VS.NET�s GUI. The GUI (Graphical User Interface) provide us with some great functionality, such as intel-i-sense, but if you are an HTML coder and don�t want any program to mess up your code, I don�t think that VS.NET is a good choice. I found it very hard to design pages in VS.NET because it changed my HTML code. Instead I tried to configure VS.NET to not touch my HTML code, but I failed. Then I decided to develop my website not using VS.NET.

The benefit of not using VS.NET

The most important benefit is, as explained above, that no program will change or modify your HTML code. When a program changes the code you have written, you can easily become confused, so you get more control if you write the pages on your own. The second benefit of writing all by yourself in a simple text editor is that you learn more about ASP.NET and develop an understanding of how ASP.NET works. When you use a GUI it often helps you with a lot of things that you don�t need to worry about.

The problem

The problem we face when not using VS.NET is that we must handle the compiling of the code-behind files ourselves. If you just write inline code and don�t use code-behind it�s just required to create a folder in wwwroot and begin programming, but if you want to use code-behind (which is great) you have to compile the files into a DLL. As you may know ASP.NET searches for the DLL files in the bin directory of your root folder. Therefore the first thing we need to do is to set up an IIS virtual directory which will be the root of our application.

Setting up an IIS virtual directory

  1. Open the Internet Services Manager. Win2K (Start / Applications / Administrative Tools / Internet Services Manager). WinXP (Start / Control Panel / Performance and Maintenance / Administrative Tools / Internet Services Manager)
  2. Locate your default website in the left tree and right click it. From the popup menu select New / Virtual Directory.
  3. Follow the steps in the wizard. In the Access permission dialog, select all boxes so you have permission to do everything.
  4. Access your site by http://localhost/Alias

Create a file that handles compiling

When your virtual directory works, you should create a bin directory inside the directory where all your compiled DLL files can be stored. After that you should create a file called compile.cmd in your root directory. Open compile.cmd file in a text editor and paste this code:

@echo off 
csc.exe /nologo /target:library /out:bin/MyDll.dll *.cs
PAUSE

What this file does is to take all *.cs files and compile them into a DLL and place the DLL in the bin folder. Change MyDll to the name of your project, or to any name you want. If you don�t have a path on your computer to the C# compiler (csc.exe) you have to write the whole path in the cmd file, or else the cmd won�t find the compiler. If you code in VB.NET you just change the path to the compiler to point to the VB compiler and replace *.cs with *.vb.

Your directory structure should now look something like this:

Wwwroot
--- Your application
------ bin
------ compile.cmd

If you have done everything correct now it should be working, so let�s test it.

Test the page

So to see if this works we create two files, a test.aspx and a code-behind file test.cs. Fill the test.aspx with this:

<%@ Page language="C#" Inherits="Test.Test" %>
<asp:Label id="label" runat="server" />

And the test.cs with this:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Test
{
    public class Test : Page
    {
        protected Label label;

        private void Page_Load(object sender, System.EventArgs e)
        {
            label.Text = "Hello ASP.NET!";
        }
    }
}

Double click compile.cmd to create the DLL. Then visit the page at http://localhost/Alias. If you see "Hello ASP.NET!" the page works. If you get any errors, please send me a mail at articles@ricki.nu and I�ll try to answer your question. Good luck!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here