ASP.Net: Simple webpage

ASP.Net is a web framework for building web sites. ASP.Net has been designed to be fully integrated with the .Net framework. ASP.Net works with Internet Information Services (IIS) to deliver the content. ASP.Net pages are with .aspx extension.

ASP.Net files can contain: sever controls, client side controls and validation controls. Other than these, it supports to place HTML objects along with HTML code, client-side script code and processing instructions for the server.

One important aspect of ASP.Net is, it can separate code from HTML. So that it will be easy to manage the projects developed using ASP.Net. ASP.Net allows to use all .Net classes within its web-pages.

Lets create a simple web page. Save the file as Default.aspx.

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

<html>
    <head>
        <title>Sample ASP.Net Page</title>
    </head>

    <body>
        <form runat="server">
            <h1>
               <%
                   string s = DateTime.Now.ToString();
                   Response.Write(s);
               %>
            </h1>
        </form>
    </body>
</html>

We have added @Page directive to instruct the language we are using in our ASP.Net page. If not mentioned language attribute; by default ASP.Net considers “Visual Basic .Net” language.

We have added <form> tag to our HTML code, and instruct the code at server side by adding runat attribute. This is an important attribute to instruct the code to run at either server side or client side.

We used DateTime class’s member Now to get the current date and time; and return it using Response.Write function.

Once we saved the “Default.aspx” file; configure this into IIS (Internet Information Services) to enable to access “Default.aspx” file through web-browser.

Look at this article to configure a folder in Internet Information Services. “How to create Virtual Directory in Internet Information Services (IIS)

Now open web-browser and type the following in address bar: We have created a virtual directory with name first for our directory where Default.aspx exists.

localhost/first/

It runs our Default.aspx page and displays current data and time on the page.

..

1 comment for “ASP.Net: Simple webpage

  1. August 30, 2015 at 5:22 PM

    we making asp code example archive
    asp code examples
    can you help us

Leave a Reply