.ASPX -> .CS generation

L

Lenard Gunda

Hi!

When I make a request to an ASPX file, it is converted into a C# source file
(given, the language is C#). This source can be seen, if I intentionally put
in something bad between <% ... %>, because it is treated as source code,
and if it is wrong, the C# compiler issues an error, when compiling this
generated .CS file.

I would like to know, what program/utility is used by IIS/ASP.NET to
generate .CS from .ASPX? Theoretically, if I would generate the .CS by hand,
and compile it, it would be possible to create websites that are fully
compiled in a DLL, right? Is there such a utility that permits me to do it?
I found no information, whatsoever, about how this part of ASP.NET works.

Thanks

Lenard
 
G

Guest

Dear Lenard

When you make a request to an ASPX file, it is not converted into C# file.

It performs object initializatio
then it loads the viewstate dat
then it performs the LoadPostData Processes Postback Dat
it then loads the object
then it raises postback change event
it processes client side postback even
then prerendering of objects take plac
viewstate is saved the
then the HTML is rendered

when you request a page, only the HTML is rendered and the scripts are executed only at the server side

there are hell a lot of things that happen when you request an aspx page :) thats why when the page first loads, i
takes sometime, the aspx page is compiled at runtime and hence takes sometime to get loaded the first time

hope it helps





----- Lenard Gunda wrote: ----

Hi

When I make a request to an ASPX file, it is converted into a C# source fil
(given, the language is C#). This source can be seen, if I intentionally pu
in something bad between <% ... %>, because it is treated as source code
and if it is wrong, the C# compiler issues an error, when compiling thi
generated .CS file

I would like to know, what program/utility is used by IIS/ASP.NET t
generate .CS from .ASPX? Theoretically, if I would generate the .CS by hand
and compile it, it would be possible to create websites that are full
compiled in a DLL, right? Is there such a utility that permits me to do it
I found no information, whatsoever, about how this part of ASP.NET works

Thank

Lenar
 
C

Cowboy

In .NET 2.0 (Whidbey), the ASPX is compiled in with the C#. In .NET 1.0, the
C# portion is compiled, but the ASPX tags are not.

As far as hiding source, the web server is supposed to accomplish this, at
least from the masses. The more proper methodology, however, is to put your
code into a CodeBehind file. MS mucks this up with .NET 2.0, IMO, by making
code in page a default, but the zero deploy, or everything compiled, solves
the danger of this coding methodology.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 
L

Lenard Gunda

It does create a C# source file!

I added:

<% if true then .. %>

to the middle of an ASPX file. It reported a CSC compile time error, and I
was able to view the file being compiled, which was auto generated, and was
a C# class derived from my code behind class of the page, that outputted
through HtmlTextWriter the page content, created and initialized the
controls based on specified attributes, and called the controls to render
themselves. It even showed me the command line that was used to compile it.
The command line contained the temporal filesnames as well.

No doubt, it does many things when requesting an ASPX file, but this step is
one of it, and I am wondering if there is a program that can be used (or
command line arguments to something) to generate this .CS file?

-Lenard

ranganh said:
Dear Lenard,

When you make a request to an ASPX file, it is not converted into C# file.

It performs object initialization
then it loads the viewstate data
then it performs the LoadPostData Processes Postback Data
it then loads the objects
then it raises postback change events
it processes client side postback event
then prerendering of objects take place
viewstate is saved then
then the HTML is rendered.

when you request a page, only the HTML is rendered and the scripts are
executed only at the server side.
there are hell a lot of things that happen when you request an aspx page
:) thats why when the page first loads, it
takes sometime, the aspx page is compiled at runtime and hence takes
sometime to get loaded the first time.
 
B

bruce barker

the parse and compile of an aspx page is done by the asp.net handler code by
building a dll per aspx page. While you could parse and build the dll's in
advance, there is no way to tell asp.net that you did it.

you will have to wait to version 2, where asp.net supports pre-compiling
the web site.


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top