Tutorials » AspNet tutorials »

Creating a new web application - behind the scenes


This article explains what happens behind the scenes when you create a new web application using Visual Studio .NET.


In the previous chapter, you created a new web application using Visual Web Developer (Or, Visual Studio.NET). Even though you did not do much work other than simply pressing few buttons, VWD created a web application for you.

Files created by VS.NET

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

You selected C:\AspSpider\MyFirstProject as the web site location. So, go to explorer and see the folder C:|AspSpider. You will notice that VWD has created a new folder called "MyFirstProject". This shows that when you create a new project, VWD creates a new folder with the name of the web site you choose.

(If you used Visual Studio.NET, look into the folder C:\Inetpub\wwwroot instead of C:\AspSpider\.)

Look inside the folder "MyFirstProject". You will see couple of files:

  • Default.aspx
  • Default.aspx.cs

    In addition to the above files, there will be a folder called "App_Data". The "default.aspx" if a web page created by VWD for you, even though you did not specify it.

    Look at the contents of the file default.aspx:


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
    </body>
    </html>


    Most of the above content is non visible html. Which means, if you run this web site now, you will see a web page with no content. Select the menu Debug > Start Without Debugging (or press "Ctrl + F5").

    This will compile and run the default web page. You will see that internet explorer will be automatically opened and your web page will be displayed. But as you can see from the content of your page in VWD, there is no visible content in the page. But if you right click on the web page in internet explorer and view the source, you will see that the source has the exact same content as what you see in the default.aspx file in VWD.

    Let us try a quick change. Go back to VWD and see the file default.aspx. See the part:

    <title>Untitled Page</title>


    Change it to

    <title>My First Web Site</title>


    Now compile and run the page again. You will see that the title of the page in the browser is changed to what you specified.

    Adding content to the page



    If you need anything to be displayed in your web page, you must add it inside the <body> tags.

    Add a welcome message as shown below, inside your BODY tags:

    <body>
    <form id="form1" runat="server">
    <div>

    Welcome to my first web page!

    </div>
    </form>
    </body>

    Note that, in ASP.NET, you must place content inside <Form> tags, within the <BODY> tags.

    Now build and view the web page by pressing Ctrl + F5. You will see the following text displayed in your web page in Internet Explorer.

    Welcome to my first web page!




  • Next Chapter: The "Build" process
    Previous Chapter: Your first web application using Visual Studio
    More Chapters: ASP.NET Tutorials
    More Tutorials: Tutorial Index



    Top Contributors
    Today
      Last 7 Daysmore...

      Awards & Gifts

      Online Members

      SivS
      More...
       
      Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India