dhrumilap
dhrumilap

Reputation: 142

how do asp.net and c# work together?

In regards to web development PHP works seamlessly embedded inside HTML pages and is parsed before the HTML itself (hence the name PHP!). I'm thinking of starting to learn ASP.NET and C# and it greatly boggles me how do these two Microsoft technologies work in tandem when compared to PHP which is a single entity in itself. I still can't understand how any logic written in C# files is tied to HTML pages that contain ASP.NET scripts.

And yes, if PHP is a scripting language, are C# and ASP.NET too server-side scripting languages??

Upvotes: 2

Views: 987

Answers (1)

Fun Mun Pieng
Fun Mun Pieng

Reputation: 6901

I will explain in a rather unconventional way, but I think this makes it easier to explain and understand.

The C# code is compiled, usually one class per page. The ASP.NET part is compiled into a class derived from the C# class.

The web server calls some function in the class to start the create the page.

Simplified it works like this:

  1. Having Page class and PageSource class where Page is derived from PageSource.
  2. Server creates an instance of Page and calls Start() on it.
  3. Start() calls the relevant functions to process the request.
  4. Some of the functions in Page output the HTML. Some call functions in PageSource.
  5. Finally after all the HTML has output, the output is sent to the client.

Refer to ASP.NET Page Life Cycle for more info.

Upvotes: 2

Related Questions