4

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?

2
  • 2
    Please dont use caps-lock. That is shouting. Commented Dec 1, 2011 at 8:27
  • @Valamas:ok I understood. Next it wont happen Commented Dec 1, 2011 at 8:29

3 Answers 3

4

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 :-)

Sign up to request clarification or add additional context in comments.

3 Comments

ok if class file complied to dll file, let us say user generate the request to web application what's happened then
You are asking about the HTTP Pipeline and how IIS responds to user requests for pages. Read west-wind.com/presentations/howaspnetworks/howaspnetworks.asp for more information.
Thanks for link, let me check and i will get back to you.
3

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.

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.