Tutorials » AspNet tutorials »

Your first web application using Visual Studio

We have been trying with small web pages created without using Visual studio. In this chapter, you will learn how to use VS.NET to create a web application.

This chapter talks about Visual Studio .NET. If you are using Visual Web Developer Express instead of Visual Studio .NET, you may skip this chapter.

Do you need Visual Studio to create web pages?

In an earlier chapter you learned how to create a simple web page without using VS.NET. You simply used notepad to type your code and save as a .aspx page.no

You can follow the same approach to develop more complex web pages. But using VS.NET can help you develop web pages much faster than using notepad.

What is Visual Studio .NET ?

Visual Studio .NET is the editor from Microsoft which allows you to write code easily and fast. Ideally, you do not need VS.NET to develop ASP.NET web sites. You can simply use notepad to type your code and use command line options to compile the code.

But you may not want to use notepad to write web pages, if you want to finish your learning in the next couple of years!!

VS.NET makes the life of a programmer very easy. It does lot of work in the backgroud for you. When you create a new web project, it automatically creates a virtual directory for you in the IIS. If you use notepad to develop web site, you will have to manually create virtual folder in IIS, which requires some knowledge about IIS. Also, it is 1-click operation in VS.NET to compile and build all web pages. In addition, VS.NET creates lot of default files and code for you, which you will have to do manually if you are not using VS.NET. If you want to display a text box or a button control, just drag and drop the control in VS.NET. There is no need to type even a single line!!

How to create a web application using Visual Studio .NET

Open the Microsoft Visual Studio .NET from your programs menu. It will come up with a default start up page. The default startup page shows the list of projects you recently worked under the title Open an Existing Project. If you are using VS.NET for the first time, you may not see any existing projects.

In the bottom of the page, you can see two buttons:

1. New Project
2. Open Project

Click the New Project button to create a new project.

If for some reason, the start up page is not visible for you, or if you cannot locate the New Project button, you can go to the menu of VS.NET and select File > New > Project

This will popup a screen as shown below, asking you to select a project type.

On the leftside of the screen, you can see the section for Project Types. Here you can select the language you want to use for your asp.net application. For this sample, let us choose "Visual Basic Projects".

See the section called "Templates". This section allows us to select the type of the project you want to create. There are several options like "Windows application", "Class Library", "ASP.NET Web Application".

Since we want to create a web application, let us select the template "ASP.NET Web Application".

The last option you have to select the is the location. If you are creating a windows application, you have to select the folder where you want the project need to be created and the name of the project. In case of a web application, we have to select the web server and the application name.

The default value for the location may be something like this:


The first part represents your web server. localhost means you are creating the web site on the local web server on your own computer.

The second part (WebApplication1) is the name of the web application. The VS.NET will create a new folder with this name and convert this folder to a virtual directory.

Let us leave the default location (http://localhost/WebApplication1) as it is and press OK. VS.NET may take few seconds to create a new web application for you.

If your IIS is not properly configured, you may get an error. If the VS.NET fails to create a web application in the above step, read how to install IIS properly.

If everything is configured correctly, VS.NET will perform the following tasks:

1. Create a new folder called "WebApplication1" (or, whatever name you select)
2. Convert the folder to a virtual directory.
3. Create couple of files for you. (If you use notepad, you will have to create each of these files manually and type the content. See how much time you saved by using VS.NET)

Files created by VS.NET

Now, let us go to the explorer and see where the project and files are created.

When you created the project, you didnt specify a physical location. Instead, you said "http://localhost/". In this case, the project will be created in the default location of your web server.

The default location for a web server is C:\Inetpub\wwwroot. Go to this folder and you will see that there is a new folder called "WebApplication1" created here. Inside that, there are several other files created by VS.NET.

Virtual Directory

Now let us go to the IIS and see the virtual directory created by VS.NET. If you do not remember how to open and work with IIS, read this chapter.

If you expand the node Default Web Site in IIS, you will notice that there is new virtual directory created with the name WebApplication1. You can right click on this virtual directory name and see various properties of this.

Next Chapter: Creating a new web application - behind the scenes
Previous Chapter: Your first web application using VWD
More Chapters: ASP.NET Tutorials
More Tutorials: Tutorial Index

Top Contributors
    Last 7 Daysmore...

    Awards & Gifts

    Online Members

    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India