AnandMohanAwasthi
AnandMohanAwasthi

Reputation: 839

How asp.net application works?

I am quite new to .NET development and I am just wondering how does it work?

My undermentioned points are:

  1. While developing ASP.NET application, under the project we have files like:
    • pagename.aspx
    • pagename.aspx.cs
    • pagename.asp.desiger.cs
  2. After adding certain functionality to pagename.aspx page, assuming I have the development required web application (this is not my concern, what is developed)
  3. Now I'm going to deploy this application, I use web deployment MSI which creates the required files in the one folder called folderdelopyed.
  4. This folder contains the files required to support this application but interesting does not contain pagename.aspx.cs and pagename.aspx.designer.cs files.

My question is if folderdelopyed does not contain .cs file, then how does it work to run the segment of code which I have written in this file called PageName.aspx.cs?

Upvotes: 4

Views: 6415

Answers (3)

Ali Foroughi
Ali Foroughi

Reputation: 4629

let me to say you something more Amazing.

you can hide your aspx file too.and put their content in to dll as same as your cs file put in dll.

you can make k aspx that just contain an address to the ddl file and no html body :D

that was greate!!! not only you can hide your cs file, you can hide you aspx file too :D

Upvotes: 0

Shadow Wizzard
Shadow Wizzard

Reputation: 66398

ASP.NET code is compiled into Dynamic-link library files, also known as DLL files.

The code you write in your code behind, which is the files with .cs extension, is compiled and put into whole new file, with .dll extension - and that file is copied to the server, to the BIN folder of your site.

Depending on what project type you choose, it's possible to have several DLL files for the web application, changing in every build - see dash's answer for more details.

On every .aspx page you have referece to what DLL file to use, as the very first line. For example:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pagename.aspx.cs" Inherits="MyNameSpace.pagename" %>

In this example, the Inherits part determines what DLL to use. How? By the namespace, which is also the name of the DLL file.

When the above .aspx is requested by a browser, the .NET engine will go to the BIN folder, look for MyNameSpace.dll and in there look for class called pagename that inherits from the base Page class - all the rest is typical life cycle of ASP.NET page.

Upvotes: 3

dash
dash

Reputation: 91550

The code in your cs files gets compiled into a dll.

For Web Application projects this is one dll

For Web Site projects, this is a dll per page.

All of the code is now in the dll's in the bin folder of the website.

You can use a tool like ILSpy (http://wiki.sharpdevelop.net/ILSpy.ashx) to look inside the dll's and see your code.

In the old days, for classic ASP, the script used to be embedded in your page - a mix of code and HTML, and was interpreted at runtime.

I like the new way more :-)

Upvotes: 5

Related Questions