469,272 Members | 1,435 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

automatic namespace importing

When you create and aspx page, this is generated by default:

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

Is there any way to automatically import more namespaces than the
default in aspx pages through some configuration in web.config?
I hate to keep all that <%@ Import Namespace="xxx" %> in all the pages...

I know in 2.0 there is a configuration tag, but I didn't find any in 1.1...
Nov 19 '05 #1
29 3918
Natan wrote:
When you create and aspx page, this is generated by default:

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

Really? The list I get is different.
Is there any way to automatically import more namespaces than the
default in aspx pages through some configuration in web.config?
I hate to keep all that <%@ Import Namespace="xxx" %> in all the
pages...
I know in 2.0 there is a configuration tag, but I didn't find any in
1.1...


I don't think so: web.config controls how the application *works*,
and the "using" directive is just a hint to the compiler that it needs
to look into these namespaces as well when looking for some classname
that you used.

I found a template that looks as if it is used for the initial code-behind file.
Try changing that to "use" the namespaces you want!
On my system it was at:
C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\DesignerTemplates\1033\NewWebFormCode.cs

Hans Kesting


Nov 19 '05 #2
> Is there any way to automatically import more namespaces than the default
in aspx pages through some configuration in web.config? No, not in web.config, but you can create your own base class (inheriting
from System.Web.UI.Page), import your namespaces in this class and make all
your pages inherit from this class instead of System.Web.UI.Page.
I hate to keep all that <%@ Import Namespace="xxx" %> in all the pages...

If you have a codebehind file with all the imports you do not need to add
Import directives to the ASPX page, these are allready imported by the code
behind class.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 19 '05 #3
Hans Kesting wrote:
Really? The list I get is different.
That is what is generated by default in .NET 1.1 (I use SP1, but i don`t
think it changes anything)
I don't think so: web.config controls how the application *works*,
and the "using" directive is just a hint to the compiler that it needs
to look into these namespaces as well when looking for some classname
that you used.
Not really. Actually there was this tag in .NET 1 beta... but for some
reason they removed. They are putting back in .NET 2.0 since it makes sense.

Web.config controls not only how your application works, but how your
pages are compiled, including linking other libraries, debugging and
other options.
I found a template that looks as if it is used for the initial code-behind file.
Try changing that to "use" the namespaces you want!
On my system it was at:
C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\DesignerTemplates\1033\NewWebFormCode.cs


Sorry, I think you are talking about code behind. I`m talking about aspx
pages. Different things, different places.
Nov 19 '05 #4
Anders Norås [MCAD] wrote:
No, not in web.config, but you can create your own base class (inheriting
from System.Web.UI.Page), import your namespaces in this class and make all
your pages inherit from this class instead of System.Web.UI.Page.
That doesn`t solve the problem that i want to import namespaces in aspx
pages...
If you have a codebehind file with all the imports you do not need to add
Import directives to the ASPX page, these are allready imported by the code
behind class.


I don't think so... try yourself and your will get an compiller error.

"Code-behind" is just the name of a directive for VS.NET find the file
that should have the class the page extends. What really happens is
inheritance of classes, and that works exactly like any other
inheritance in .NET.

Code-behind and ASPX pages are not the same thing, they are separated.
Each one is one class and each one has its own using directives.
Nov 19 '05 #5
I think what you are all looking for is
building a custom Web Form Wizard.

There's complete instructions at :
http://msdn.microsoft.com/library/de...stomwebwiz.asp

Once you do that, your custom template will
be available via the "Add a New Item" menu.

Juan T. Llibre
===========
"Natan" <nv********@mandic.com.br> wrote in message
news:Ow**************@TK2MSFTNGP12.phx.gbl...
Anders Norås [MCAD] wrote:
No, not in web.config, but you can create your own base class (inheriting
from System.Web.UI.Page), import your namespaces in this class and make
all your pages inherit from this class instead of System.Web.UI.Page.


That doesn`t solve the problem that i want to import namespaces in aspx
pages...
If you have a codebehind file with all the imports you do not need to add
Import directives to the ASPX page, these are allready imported by the
code behind class.


I don't think so... try yourself and your will get an compiller error.

"Code-behind" is just the name of a directive for VS.NET find the file
that should have the class the page extends. What really happens is
inheritance of classes, and that works exactly like any other inheritance
in .NET.

Code-behind and ASPX pages are not the same thing, they are separated.
Each one is one class and each one has its own using directives.

Nov 19 '05 #6
Juan T. Llibre [MVP] wrote:
I think what you are all looking for is
building a custom Web Form Wizard.

There's complete instructions at :
http://msdn.microsoft.com/library/de...stomwebwiz.asp

Once you do that, your custom template will
be available via the "Add a New Item" menu.


No, its about importing namespaces in aspx pages.
VS.NET has nothing to do with it.
Nov 19 '05 #7
re:
No, its about importing namespaces in aspx pages.
VS.NET has nothing to do with it.
Huh ?

Your question was :
re:When you create and aspx page, this is generated by default:
Presumably, that was generated by VS,
so VS.NET *has* something to do with it, doesn't it ?

re:using System;
using System.Collections; etc.

Those are the imported namespaces in a .cs file

re: through some configuration in web.config?


No. You can't do it via web.config but
you *can* do it by defining a new .aspx page
template, as explained in that article.

http://msdn.microsoft.com/library/de...omwebwiz.aspTo import any number, or all classes, if you choose,all you have to do is create a "Custom Web Form"i.e., aspx page, Wizard, and add the controls/classesyou want to the template.Once you do that, the additional classes you specifywill be automatically included in your code-behind filefor all aspx pages which you create with the CustomWeb Form template.If I missed something, please let me know.Also, if you find a better way to do that, please post it.Juan T. Llibre==========="Natan" <nv********@mandic.com.br> wrote in messagenews:eX**************@TK2MSFTNGP10.phx.gbl. ..> Juan T. Llibre [MVP] wrote:>> I think what you are all looking for is>> building a custom Web Form Wizard.>>>> There's complete instructions at :>>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/customwebwiz.asp>>>> Once you do that, your custom template will>> be available via the "Add a New Item" menu.>> No, its about importing namespaces in aspx pages.> VS.NET has nothing to do with it.

Nov 19 '05 #8
Wow, the text formatting was really mangled.
Here's a properly formatted ( I hope ) post:

re:
No, its about importing namespaces in aspx pages.
VS.NET has nothing to do with it.
Huh ?

Your question was :
re:When you create and aspx page, this is generated by default:
Presumably, that was generated by VS,
so VS.NET *has* something to do with it, doesn't it ?

re:using System;
using System.Collections; etc.

Those are the imported namespaces in a .cs file

re: through some configuration in web.config?


No. You can't do it via web.config but
you *can* do it by defining a new .aspx page
template, as explained in that article :

http://msdn.microsoft.com/library/de...stomwebwiz.asp

To import any number, or all classes, if you choose,
all you have to do is create a "Custom Web Form",
i.e., aspx page, Wizard, and add the controls/classes
you want to the template.

Once you do that, the additional classes you specify
will be automatically included in your code-behind file
for all aspx pages which you create with the Custom
Web Form template.

If I missed something, please let me know.
Also, if you find a better way to do that, please post it.

Juan T. Llibre
==========

Nov 19 '05 #9
Juan T. Llibre [MVP] wrote:
Huh ?
Sorry, but probably you have no idea about what i'm talking about.

Your question was :
When you create and aspx page, this is generated by default:
Presumably, that was generated by VS,
so VS.NET *has* something to do with it, doesn't it ?


No. Creating an aspx page is "create an empty file with .aspx extension
using notepad and run it". There is no need for VS.NET... And actually
even though I have VS.NET installed I think it is much more productive
to not use it for ASP.NET pages.

So, if you had no idea that you could do it:

start menu -> run -> notepad
paste this:

<%@ Page Language="C#"%>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
bla
}
</script>

Save as .ASPX and run. There will be an error because of the "bla" and
there is a link tho show the "Complete Compilation Source". That is the
ASPX page that is actually compiled.

If you specify an Inherits="xxxx" in the Page directive, what happens is
that this class extends yous class. "Code behind" directive is only a
way to tell vs.net what file is associated so it can create the treeview
or open it. It is just a base class for inheritance, nothing more. You
can do the same things without it.
re:
using System;
using System.Collections;
etc.

Those are the imported namespaces in a .cs file


No, those are namespaces imported by default when ASP.NET parses your
..ASPX page and automatically generates a class in the ASP namespace to
compile. See above...

No. You can't do it via web.config but
you *can* do it by defining a new .aspx page
template, as explained in that article.


Yes, that's what thought. There was this functionality in .net 1 beta
but was removed for some reason. It's coming back in .NET 2.0 (thank god)

* http://msdn2.microsoft.com/library/bd818k6y.aspx

But the solution has nothing to do with templates or VS.NET. The only
way I see to solve this is with <%@ Import Namespace="xxx" %> in every page.
Nov 19 '05 #10
re:
No. You can't do it via web.config but
you *can* do it by defining a new .aspx page
template, as explained in that article.


Yes, that's what thought. There was this functionality in .net 1 beta but
was removed for some reason. It's coming back in .NET 2.0 (thank god)

* http://msdn2.microsoft.com/library/bd818k6y.aspx


See
http://msdn.microsoft.com/library/de...webwiz.aspThat article says that VS 2002 and VS 2003 can do that.( VS 2002 = .NET 1.0 , and VS 2003 = NET 1.1 )re:<imports> <add namespace="MyNamespace"/></imports>You must realize that loading a whole bunch of Namespacesat the Application level involves a serious waste of resources.It's *far* better to create a custom Web Form templateand only load the Namespaces at the Page level.re:> No. Creating an aspx page is "create an empty file with .aspx extensionusing notepad and run it". There is no need for VS.NET.If you're intent on using Notepad, and have VS,you must be some sort of a masochist ... :-)For that, you might as well have a pre-written .txt filewhich you open and save as .aspx, with all the stuffyou want inserted.When you defined your question as :"When you create and aspx page, this is generated by default"the obvious conclusion is that you're using VS.NET,since Notepad doesn't "generate" anything.re:> Sorry, but probably you have no idea about what i'm talking about.If you change your mind between posts it'shard to know what you're talking about. :-)Juan T. Llibre==========="Natan" <nv********@mandic.com.br> wrote in messagenews:em**************@TK2MSFTNGP11.phx.gbl. ..> Juan T. Llibre [MVP] wrote:>> Huh ?>> Sorry, but probably you have no idea about what i'm talking about.>>>> Your question was :>>>>>When you create and aspx page, this is generated by default:>>>> Presumably, that was generated by VS,>> so VS.NET *has* something to do with it, doesn't it ?>> No. Creating an aspx page is "create an empty file with .aspx extensionusing notepad and run it". There is no need for VS.NET... And actually eventhough I have VS.NET installed I think it is much more productive to not useit for ASP.NET pages.>> So, if you had no idea that you could do it:>> start menu -> run -> notepad> paste this:>> <%@ Page Language="C#"%>> <script runat="server">> void Page_Load(object sender, EventArgs e)> {> bla> }> </script>>> Save as .ASPX and run. There will be an error because of the "bla" andthere is a link tho show the "Complete Compilation Source". That is the ASPXpage that is actually compiled.>> If you specify an Inherits="xxxx" in the Page directive, what happens isthat this class extends yous class. "Code behind" directive is only a way totell vs.net what file is associated so it can create the treeview or openit. It is just a base class for inheritance, nothing more. You can do thesame things without it.>>> re:>>>>>using System;>>>using System.Collections;>>>> etc.>>>> Those are the imported namespaces in a .cs file>> No, those are namespaces imported by default when ASP.NET parses your.ASPX page and automatically generates a class in the ASP namespace tocompile. See above...>>>> No. You can't do it via web.config but>> you *can* do it by defining a new .aspx page>> template, as explained in that article.>> Yes, that's what thought. There was this functionality in .net 1 beta butwas removed for some reason. It's coming back in .NET 2.0 (thank god)>> * http://msdn2.microsoft.com/library/bd818k6y.aspx>> But the solution has nothing to do with templates or VS.NET. The only wayI see to solve this is with <%@ Import Namespace="xxx" %> in every page.

Nov 19 '05 #11
Juan T. Llibre [MVP] wrote:
See
http://msdn.microsoft.com/library/de...stomwebwiz.asp
That article says that VS 2002 and VS 2003 can do that.( VS 2002 =

..NET 1.0 , and VS 2003 = NET 1.1 )

The article teaches how to extend visual studio creating templates for
webforms and code behind. Nothing to do with what i asked.

Visual Studio CAN'T do that because it's not up to VS how ASP.NET pages
are parsed and compiled.

I suggest you take a look at .NET documentation to understand how
asp.net pages work so you will understand what i'm talking about.
Nov 19 '05 #12
I wonder why this reformatting is happening.

If I send in text format, the format is lost.
But, it's preserved if I send HTML.

Here's a reformatted reply:
re:
No. You can't do it via web.config but
you *can* do it by defining a new .aspx page
template, as explained in that article.
Yes, that's what thought. There was this functionality in .net 1 beta but
was removed for some reason. It's coming back in .NET 2.0 (thank god)

* http://msdn2.microsoft.com/library/bd818k6y.aspx


See
http://msdn.microsoft.com/library/de...stomwebwiz.asp

That article says that VS 2002 and VS 2003 can do that.
( VS 2002 = .NET 1.0 , and VS 2003 = NET 1.1 )
re:
<imports>
<add namespace="MyNamespace"/>
</imports>

You must realize that loading a whole bunch of Namespaces
at the Application level involves a serious waste of resources.

It's *far* better to create a custom Web Form template
and only load the Namespaces at the Page level.

re:No. Creating an aspx page is "create an empty file
with .aspx extension using notepad and run it".
There is no need for VS.NET.
If you're intent on using Notepad, and have VS,
you must be some sort of a masochist ... :-)

For that, you might as well have a pre-written .txt file
which you open and save as .aspx, with all the stuff
you want inserted.

When you defined your question as :
"When you create and aspx page, this is generated by default"
the obvious conclusion is that you're using VS.NET,
since Notepad doesn't "generate" anything.

re: Sorry, but probably you have no idea
about what i'm talking about.


If you change your mind between posts it's
hard to know what you're talking about. :-)


Juan T. Llibre
===========
Nov 19 '05 #13
re:
Nothing to do with what i asked.
<sigh>

Would you please re-explain what it is you asked ?

( Particularly, how Notepad would "generate" what you want inserted ? )


Juan T. Llibre
===========
"Natan" <nv********@mandic.com.br> wrote in message news:uj**************@TK2MSFTNGP11.phx.gbl... Juan T. Llibre [MVP] wrote:
See
http://msdn.microsoft.com/library/de...stomwebwiz.asp
That article says that VS 2002 and VS 2003 can do that.( VS 2002 =

.NET 1.0 , and VS 2003 = NET 1.1 )

The article teaches how to extend visual studio creating templates for
webforms and code behind. Nothing to do with what i asked.

Visual Studio CAN'T do that because it's not up to VS how ASP.NET pages
are parsed and compiled.

I suggest you take a look at .NET documentation to understand how
asp.net pages work so you will understand what i'm talking about.

Nov 19 '05 #14
Juan T. Llibre [MVP] wrote:
re:
>Nothing to do with what i asked.


<sigh>

Would you please re-explain what it is you asked ?

( Particularly, how Notepad would "generate" what you want inserted ? )


Notepad doesn't generate anything, asp.net does.

Sorry, i respect you, but i won't explain again since you don't know
what i'm talking about. What i asked is written in the first post...
Nov 19 '05 #15
TJS
I don't believe there is such a thing.

I think this is one of the big pitfalls with .net, there is no way of
knowing which namespaces to import. I always have to test and get an error
message to find out what is needed. usually end up putting in too many

"Natan" <nv***@mandic.com.br> wrote in message
news:ur**************@TK2MSFTNGP12.phx.gbl...
When you create and aspx page, this is generated by default:

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

Is there any way to automatically import more namespaces than the default
in aspx pages through some configuration in web.config?
I hate to keep all that <%@ Import Namespace="xxx" %> in all the pages...

I know in 2.0 there is a configuration tag, but I didn't find any in
1.1...

Nov 19 '05 #16
TJS wrote:
I don't believe there is such a thing.
Yeah... I have seen lots of people asking about this... .NET 2.0 will
solve this. until this day, lots of @import to deal... hope they don't
remove it again when the final comes out.
I think this is one of the big pitfalls with .net, there is no way of
knowing which namespaces to import. I always have to test and get an error
message to find out what is needed. usually end up putting in too many


I don't think there is any problem having tons of "using", since it is
used by the compiler to find the types. Once it compiles to MSIL, every
type is the full qualified path, so it's not like it is searching all
the namespaces again everytime it runs. So there is really no difference
having 1 or 100 usings... But I may be wrong.

Thanks for understanding me :-p
Nov 19 '05 #17
re:
Sorry, i respect you, but i won't explain again since you don't know
what i'm talking about. What i asked is written in the first post.
Nathan,

Your original question was :
Is there any way to automatically import more namespaces than
the default in aspx pages through some configuration in web.config?
I hate to keep all that <%@ Import Namespace="xxx" %> in all the pages...
The answer is *no*, you cannot do that via web.config,
at least not until .Net 2.0 is your Framework version.

Your original premise:When you create and aspx page, this is generated by default:
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

is flawed, as you don't necessarily have to import
all those namespaces, and Notepad doesn't
"generate" anything like that.

In fact, Notepad doesn't generate anything.

In order to "generate" anything,
you must have been using VS.NET.

When I create a new C# Web Project,
the following classes are imported by default:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

That's a far cry from what you're
saying is imported by default.

Like I said, if you need more, or even less, classes
imported by default, in ASP.Net 1.0 or 1.1, if you're
using VS.NET 2002 or VS.NET 2003, the best
way to do it is to create a custom template for aspx pages.

Clearly, with Notepad you won't be able to do that,
but Notepad is your very particular pre-requisite.

For anybody else, using VS.NET 2002 or 2003,
creating a custom aspx template will do the job
neatly, for ASP.NET 1.0 or 1.1.

For anybody using VS.NET 2005 ( .Net Framework 2.0 )
one way to do it is to use the <imports> statement in
web.config, although doing that will generate excessive
memory usage.

The best way to do that in VS.NET 2005 is, still, to create
a Custom Web Form template which you can use for
individual pages, but not load the classes for all pages,
since that would, again, cause excessive memory consumption.

If you want to acknowledge that, fine.
If you don't want to acknowledge that, it's fine, too.

Let's move on, please.

Juan T. Llibre
===========

"Natan" <nv********@mandic.com.br> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl... Juan T. Llibre [MVP] wrote:
re:
>Nothing to do with what i asked.


<sigh>

Would you please re-explain what it is you asked ?

( Particularly, how Notepad would "generate" what you want inserted ? )


Notepad doesn't generate anything, asp.net does.

Sorry, i respect you, but i won't explain again since you don't know
what i'm talking about. What i asked is written in the first post...

Nov 19 '05 #18
Juan T. Llibre [MVP] wrote:
is flawed, as you don't necessarily have to import
all those namespaces, and Notepad doesn't
"generate" anything like that.
Those are generated automatically by ASP.NET when it parses the page and
creates the class.
In fact, Notepad doesn't generate anything.

In order to "generate" anything,
you must have been using VS.NET.
Of course notepad doesn't generate anything. (duh) You are getting it
wrong...

The fact is that you didn't understand how aspx pages works. Since the
page itself is a class, the page is converted to a class extending
System.Web.UI.Page and compiled. Not the code behind, but the page. All
the HTML you create is parsed and there is a lot of LiteralControls to
hold all the html you write.

When you use code behind, what happens actually is that this class
ASP.NET creates automatically from the aspx file inherits from the class
you (or vs.net) specify instead of System.Web.UI.Page.

And this code generated by asp.net must be a class, and by default have
all those using clauses.

Do the test, copy the code i posted before, paste in notepad, save as
aspx file and run it in your wwwroot. You will see what i'm talking
about...

When I create a new C# Web Project,
the following classes are imported by default:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

That's a far cry from what you're
saying is imported by default.
Yes. That's what you get when you use CodeBehind... but since i told you
i'm not talking about code behind neither VS.NET...
If you want to acknowledge that, fine.
If you don't want to acknowledge that, it's fine, too.

Let's move on, please.


The problem here is that i'm talking about A and you're talking about B.
You didn't understand what i'm talking about and want me to accept your
answer. Please, read again the posts and try to understand. You are the
one who must acknowledge things.

Let's move on... =)
Nov 19 '05 #19
Natan,

Could you let me know how you determined that
Those are generated automatically by ASP.NET
when it parses the page and creates the class.
re: Since the page itself is a class, the page is converted
to a class extending System.Web.UI.Page and compiled. Not the code behind, but the page. All the HTML you create
is parsed and there is a lot of LiteralControls to hold all the html you write.
Where did you find the list of Imports statements you quoted ?

i.e., I compiled the test you posted, to check it out.

---------------
<%@ Page Language="C#"%>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
bla;
}
</script>
----------------------

( I added the ";", so it would compile )

You requested that I do this :
------------------------------------------
"Save as .ASPX and run. There will be an error because of the "bla" and
there is a link tho show the "Complete Compilation Source". That is the
ASPX page that is actually compiled.
---------------------------------

I did that and got this list of compiled page resources
in the "Complete Compilation Source" :

System.EnterpriseServices.dll
acme.dll
global.asaxxi3ltqav.dll
System.Web.Services.dll
System.dll
System.Drawing.dll
System.Web.dll
System.Data.dll
mscorlib.dll
System.Web.Mobile.dll
System.Xml.dll
i8fuexe.dll
i8fuexe.0.cs
i8fuexe.1.cs

Then, you said that:
----------------------------
If you specify an Inherits="xxxx" in the Page directive,
what happens is that this class extends yous class.
---------------------------

So, I added
<%@ Import Namespace ="System.Diagnostics" %>
to the page, since you said that would add a namespace
which should have been compiled, if you're right, given that
you said that :
-----------------------------------
"those are namespaces imported by default when ASP.NET
parses your .ASPX page and automatically generates a class
in the ASP namespace to compile.
But the solution has nothing to do with templates or VS.NET.
The only way I see to solve this is with
<%@ Import Namespace="xxx" %> in every page."
--------------------------------------

I, then, added
<%@ Import Namespace ="System.Diagnostics" %>
to satisfy your requisite, as you said to do.

But, the new list of compiled page resources only has :

System.EnterpriseServices.dll
acme.dll
global.asaxxi3ltqav.dll
System.Web.Services.dll
System.dll
System.Drawing.dll
System.Web.dll
System.Data.dll
mscorlib.dll
System.Web.Mobile.dll
System.Xml.dll
7ion-da0.dll
7ion-da0.0.cs
7ion-da0.1.cs

and does *not* have a reference to "System.Diagnostics.dll",
as it should have been added if I understood what you say,
and what you explain is correct, that the "Imports" Page
statement would add the "System.Diagnostics" to the list
of compiled resources.

If I did *not* understand what you said, please detail the method(s)
you used to determine which dll's are included in the compiled aspx page,
and how/when/where another namespace, added via <%@ Import Namespace ="Bla.Bla" %>
to the page, is added to the compiled list of resources for that page.

This will make your position a bit easier to understand.
Please take the time to document this, as I have done.

Don't take offense. Just prove your point.

This is extremely interesting, and I'd like to know
if you are actually right, because it would certainly
change the way I've understood, up until now,
the .NET Framework and ASP.NET's inner workings.


Juan T. Llibre
===========
"Natan" <nv********@mandic.com.br> wrote in message news:OG**************@TK2MSFTNGP09.phx.gbl... Juan T. Llibre [MVP] wrote:
is flawed, as you don't necessarily have to import
all those namespaces, and Notepad doesn't
"generate" anything like that.


Those are generated automatically by ASP.NET when it parses the page and
creates the class.
In fact, Notepad doesn't generate anything.

In order to "generate" anything,
you must have been using VS.NET.


Of course notepad doesn't generate anything. (duh) You are getting it
wrong...

The fact is that you didn't understand how aspx pages works. Since the
page itself is a class, the page is converted to a class extending
System.Web.UI.Page and compiled. Not the code behind, but the page. All
the HTML you create is parsed and there is a lot of LiteralControls to
hold all the html you write.

When you use code behind, what happens actually is that this class
ASP.NET creates automatically from the aspx file inherits from the class
you (or vs.net) specify instead of System.Web.UI.Page.

And this code generated by asp.net must be a class, and by default have
all those using clauses.

Do the test, copy the code i posted before, paste in notepad, save as
aspx file and run it in your wwwroot. You will see what i'm talking
about...

When I create a new C# Web Project,
the following classes are imported by default:

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

That's a far cry from what you're
saying is imported by default.


Yes. That's what you get when you use CodeBehind... but since i told you
i'm not talking about code behind neither VS.NET...
If you want to acknowledge that, fine.
If you don't want to acknowledge that, it's fine, too.

Let's move on, please.


The problem here is that i'm talking about A and you're talking about B.
You didn't understand what i'm talking about and want me to accept your
answer. Please, read again the posts and try to understand. You are the
one who must acknowledge things.

Let's move on... =)

Nov 19 '05 #20
Juan T. Llibre [MVP] wrote:
Natan,

Could you let me know how you determined that
> Those are generated automatically by ASP.NET
> when it parses the page and creates the class.

Really, I don't remember. Probably i just figured out. But it's just how
asp.net works. It parses the ASPX page and creates a class.
Where did you find the list of Imports statements you quoted ? .... I did that and got this list of compiled page resources
in the "Complete Compilation Source" :

System.EnterpriseServices.dll
acme.dll
global.asaxxi3ltqav.dll
System.Web.Services.dll
System.dll
System.Drawing.dll
System.Web.dll
System.Data.dll
mscorlib.dll
System.Web.Mobile.dll
System.Xml.dll
i8fuexe.dll
i8fuexe.0.cs
i8fuexe.1.cs

Close! Very close :-p
There are two links in the error page. You probably opened the first,
and those are the assemblies your page is linked against. In case you
don't find it, run some aspx files in your IIS, then take a look at your
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Tempo rary ASP.NET Files

ASP.NET should keep cache of compiled pages in that directory. (you can
find this dir in the end of the compilation line you got this
assemblies). Enter any application folder, then there are some folders
with random names. Open them, you will end up in a directory with lots
of files, some of them are .CS.

Open any CS, you will see that it is the class ASP.NET parser generates
for every ASPX page. There are some .cmdline that are the command line
used to compile the class. After compiling the page, asp.net uses the
compiled assembly to show the page. (even though you compiled your
webapp with code behind, aspx pages are still compilled individually
when they run, extending the base class)

See, there is a difference in linking libraries and importing
namespaces. The reason you didn't see difference in the reference list
is because System.Diagnostic namespace is half in mscorlib.dll and half
in System.dll, that are already included in the list of references.
Namespaces do not map to assemblies directly. e.g. most of "System"
namespace is in mscorlib.dll, not in System.dll. All the namespaces in
..NET BCL are included in something like 8 DLLs.

using directive only tell the compiler what namespaces to look for
types, linking libraries tell in what assemblies he should look for
namespaces.

@ Import directive is just a way to include another "using" in the
generated class, because every "script runat='server' block is put
inside the page class where you can't insert any using directive. e.g.,
if you have an @Import directive to a namespace, but the assembly you
are linking to is neither in bin nor in GAC, the compiler will raise an
error that it cannot load the namespace.

To explain my point, I must tell you why it is important to me to
automatically import namespaces in aspx files. I prefer to work with
"script runat='server'" and not code behind because:

1. VS.NET html editor sucks in a way i can't even describe it
2. VS.NET is against XHTML
3. VS.NET and most of WebControls are against CSS and "tableless"
standards and principles
4. It is much easier to work with code and html in the same page. I can
control how things are done and it's much easier than old asp (in
vs.net, everything must be done twice with code behind and even though
it generates the code, you must use the designer to create everything,
what is less productive if you know html and know what you are doing)
5. I don't have to use most of WebControls since HtmlControls work
perfectly fine and are much better to create cross browser applications.
You will notice 70% of webcontrols were created to make vs.net work in
design time, but they are not needed at all.
6. I don't have to worry about design time support. I worked with html
my entire life and it is much easier to write
<div id='div' runat='server'></div> than drag and dropping asp:panels
that render divs anyway.
7. I don't have to deal with front page extensions, my directory tree is
always clean and have only what it needs, no need to export to another
directory.

So, the fact is that i hardly use code behind. I like my UltraEdit or
dreamweaver for pages, and keep VS to create the libraries. That's why I
need to <%@ Import %> one or two namespaces in my class. At least the
business logic and entities namespace must be available to pages since
they call methods to databind and other stuff. All the heavy logic are
stored in dlls, so i don't need to worry about people looking at my code.

Well... back to the subject.

I attached to this post the output generated by asp.net parser, cached
in Temporary ASP.NET Files, and the command line used to compile, so if
you don't find it, here is your reference.

Note the "public class bla_aspx : System.Web.UI.Page" because the page
is named "bla.aspx", and the "script runat='server'" in the middle of
the class, where the parses puts it. If you use code behind, what
happens is that this class uses your class as base class, not Page.

I suggest you to put some html, some runat='server' controls and see
what is the output in the class. It's good to understand how it really
works.
If I did *not* understand what you said, please detail the method(s)
you used to determine which dll's are included in the compiled aspx page,
and how/when/where another namespace, added via <%@ Import Namespace
="Bla.Bla" %>
to the page, is added to the compiled list of resources for that page.
This will make your position a bit easier to understand.
Please take the time to document this, as I have done.

Don't take offense. Just prove your point.
This is extremely interesting, and I'd like to know
if you are actually right, because it would certainly
change the way I've understood, up until now,
the .NET Framework and ASP.NET's inner workings.


I'm not an MVP... :-p but this is just how it works. take a tour in
system.web.dll, in System.Web.Compilation through ildasm and you will
see some classes that does the parsing and compiling. probably there is
something in MSDN about this stuff.

I hope it helps to prove my point.

You can send me an email if you want. Just take the "-list" part off my
email.

[]'s

//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

namespace ASP {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
[System.Runtime.CompilerServices.CompilerGlobalScop eAttribute()]
public class bla_aspx : System.Web.UI.Page, System.Web.SessionState.IRequiresSessionState {

private static int __autoHandlers;

private static bool __initialized = false;

private static System.Collections.ArrayList __fileDependencies;
#line 2 "D:\Root\bla.aspx"

void Page_Load(object sender, EventArgs e)
{
bla
}

#line default
#line hidden

public bla_aspx() {
System.Collections.ArrayList dependencies;
if ((ASP.bla_aspx.__initialized == false)) {
dependencies = new System.Collections.ArrayList();
dependencies.Add("D:\\Root\\bla.aspx");
ASP.bla_aspx.__fileDependencies = dependencies;
ASP.bla_aspx.__initialized = true;
}
this.Server.ScriptTimeout = 30000000;
}

protected override int AutoHandlers {
get {
return ASP.bla_aspx.__autoHandlers;
}
set {
ASP.bla_aspx.__autoHandlers = value;
}
}

protected System.Web.HttpApplication ApplicationInstance {
get {
return ((System.Web.HttpApplication)(this.Context.Applica tionInstance));
}
}

public override string TemplateSourceDirectory {
get {
return "/";
}
}

private void __BuildControlTree(System.Web.UI.Control __ctrl) {
}

protected override void FrameworkInitialize() {
this.__BuildControlTree(this);
this.FileDependencies = ASP.bla_aspx.__fileDependencies;
this.EnableViewStateMac = true;
this.Request.ValidateInput();
}

public override int GetTypeHashCode() {
return 5381;
}
}
}

/t:library /utf8output /R:"c:\windows\microsoft.net\framework\v1.1.4322\ms corlib.dll" /R:"c:\windows\assembly\gac\system.enterpriseservic es\1.0.5000.0__b03f5f7f11d50a3a\system.enterprises ervices.dll" /R:"c:\windows\microsoft.net\framework\v1.1.4322\te mporary asp.net files\root\78f3146f\a4b7e5c9\assembly\dl2\d7d24fd5 \102994f1_06a6c401\chat2.dll" /R:"c:\windows\assembly\gac\system.data\1.0.5000.0_ _b77a5c561934e089\system.data.dll" /R:"c:\windows\assembly\gac\system.web.mobile\1.0.5 000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"c:\windows\assembly\gac\system.drawing\1.0.5000 .0__b03f5f7f11d50a3a\system.drawing.dll" /R:"c:\windows\assembly\gac\system.xml\1.0.5000.0__ b77a5c561934e089\system.xml.dll" /R:"c:\windows\assembly\gac\system.web.services\1.0 .5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"c:\windows\assembly\gac\system\1.0.5000.0__b77a 5c561934e089\system.dll" /R:"c:\windows\assembly\gac\system.web\1.0.5000.0__ b03f5f7f11d50a3a\system.web.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\ Temporary ASP.NET Files\root\78f3146f\a4b7e5c9\djudr-s0.dll" /D:DEBUG /debug+ /optimize- /warnaserror /w:1 "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temp orary ASP.NET Files\root\78f3146f\a4b7e5c9\djudr-s0.0.cs"
Nov 19 '05 #21
I think we may be nearer to narrowing down
what is happening here.

What is included in that file you sent :
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
is autogenerated by the csc compiler, *not* by the ASP.NET
engine, which directly contradicts your statement that :
Those are generated automatically by ASP.NET
when it parses the page and creates the class.
That generated output is *not* the result of parsing and compiling
the page by ASP.NET, but the result of the csc.exe compiler
compiling the page, just as it would have been the result of the
vbc.exe compiler, if VB had been the language declared in the page.

I have quite an interesting .NET/ASP.NET setup, because I'm running
Windows Server 2003, which includes .Net Framework 1.1 "out of the box",
which means I didn't have to install it.

I afterwards installed VS.NET 2005, which installed .Net Framework 2.0.

Here's the interesting thing :

I've *never* compiled any .NET 1.1.4322.2032 projects
( like for example, the ASP.NET Forums... ) with VS.NET 2005.

If I did that, the projects would get updated to VS.NET 2005 format,
and that would ruin the possibilities of maintaining them as ASP.NET 1.1 projects.

Here's the key:

I did a search for source files ( .vb or .cs ) of the type which have the
"This code was generated by a tool" disclaimer, in the "Temporary ASP.NET files"
folder, and *only* found files generated by VS.NET 2005 with this disclaimer :

"This code was generated by a tool.
Runtime Version:2.0.40607.16"

I did *not* find any files with the disclaimer for "Runtime Version 1.1.4322.2032",
even though they were equally processed by ASP.NET.

*No* .cs or .vb files for the runtime version 1.1.4322.2032 were found in the "Temporary ASP.NET files
folder" for the .Net Framework 1.1.4322.2032 *even though they had been *equally* processed by ASP.NET*.

This leads to the inescapable conclusion that it is *not*
ASP.NET which is compiling the .aspx files, as you claim,
and that it *is* the underlying compiler ( csc.exe or vbc.exe )
which is doing the compiling, the results of which *then* are
processed by aspnet_isapi.dll.

re: it's just how asp.net works.
It parses the ASPX page and creates a class.
No. The aspx page is compiled by either csc.exe or vbc.exe,
depending on the language declared for the page, and ASP.NET
( aspnet_isapi.dll ) has nothing to do with the code until it processes
the MSIL generated by the appropiate compiler.

Your turn...

Juan T. Llibre
===========
"Natan" <nv***@mandic.com.br> wrote in message news:ec**************@TK2MSFTNGP09.phx.gbl... Juan T. Llibre [MVP] wrote:
Natan,

Could you let me know how you determined that
> Those are generated automatically by ASP.NET
> when it parses the page and creates the class.

Really, I don't remember. Probably i just figured out. But it's just how
asp.net works. It parses the ASPX page and creates a class.
Where did you find the list of Imports statements you quoted ?

...
I did that and got this list of compiled page resources
in the "Complete Compilation Source" :

System.EnterpriseServices.dll
acme.dll
global.asaxxi3ltqav.dll
System.Web.Services.dll
System.dll
System.Drawing.dll
System.Web.dll
System.Data.dll
mscorlib.dll
System.Web.Mobile.dll
System.Xml.dll
i8fuexe.dll
i8fuexe.0.cs
i8fuexe.1.cs



Close! Very close :-p
There are two links in the error page. You probably opened the first,
and those are the assemblies your page is linked against. In case you
don't find it, run some aspx files in your IIS, then take a look at your
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Tempo rary ASP.NET Files

ASP.NET should keep cache of compiled pages in that directory. (you can
find this dir in the end of the compilation line you got this
assemblies). Enter any application folder, then there are some folders
with random names. Open them, you will end up in a directory with lots
of files, some of them are .CS.

Open any CS, you will see that it is the class ASP.NET parser generates
for every ASPX page. There are some .cmdline that are the command line
used to compile the class. After compiling the page, asp.net uses the
compiled assembly to show the page. (even though you compiled your
webapp with code behind, aspx pages are still compilled individually
when they run, extending the base class)

See, there is a difference in linking libraries and importing
namespaces. The reason you didn't see difference in the reference list
is because System.Diagnostic namespace is half in mscorlib.dll and half
in System.dll, that are already included in the list of references.
Namespaces do not map to assemblies directly. e.g. most of "System"
namespace is in mscorlib.dll, not in System.dll. All the namespaces in
.NET BCL are included in something like 8 DLLs.

using directive only tell the compiler what namespaces to look for
types, linking libraries tell in what assemblies he should look for
namespaces.

@ Import directive is just a way to include another "using" in the
generated class, because every "script runat='server' block is put
inside the page class where you can't insert any using directive. e.g.,
if you have an @Import directive to a namespace, but the assembly you
are linking to is neither in bin nor in GAC, the compiler will raise an
error that it cannot load the namespace.

To explain my point, I must tell you why it is important to me to
automatically import namespaces in aspx files. I prefer to work with
"script runat='server'" and not code behind because:

1. VS.NET html editor sucks in a way i can't even describe it
2. VS.NET is against XHTML
3. VS.NET and most of WebControls are against CSS and "tableless"
standards and principles
4. It is much easier to work with code and html in the same page. I can
control how things are done and it's much easier than old asp (in
vs.net, everything must be done twice with code behind and even though
it generates the code, you must use the designer to create everything,
what is less productive if you know html and know what you are doing)
5. I don't have to use most of WebControls since HtmlControls work
perfectly fine and are much better to create cross browser applications.
You will notice 70% of webcontrols were created to make vs.net work in
design time, but they are not needed at all.
6. I don't have to worry about design time support. I worked with html
my entire life and it is much easier to write
<div id='div' runat='server'></div> than drag and dropping asp:panels
that render divs anyway.
7. I don't have to deal with front page extensions, my directory tree is
always clean and have only what it needs, no need to export to another
directory.

So, the fact is that i hardly use code behind. I like my UltraEdit or
dreamweaver for pages, and keep VS to create the libraries. That's why I
need to <%@ Import %> one or two namespaces in my class. At least the
business logic and entities namespace must be available to pages since
they call methods to databind and other stuff. All the heavy logic are
stored in dlls, so i don't need to worry about people looking at my code.

Well... back to the subject.

I attached to this post the output generated by asp.net parser, cached
in Temporary ASP.NET Files, and the command line used to compile, so if
you don't find it, here is your reference.

Note the "public class bla_aspx : System.Web.UI.Page" because the page
is named "bla.aspx", and the "script runat='server'" in the middle of
the class, where the parses puts it. If you use code behind, what
happens is that this class uses your class as base class, not Page.

I suggest you to put some html, some runat='server' controls and see
what is the output in the class. It's good to understand how it really
works.
If I did *not* understand what you said, please detail the method(s)
you used to determine which dll's are included in the compiled aspx page,
and how/when/where another namespace, added via <%@ Import Namespace
="Bla.Bla" %>
to the page, is added to the compiled list of resources for that page.
This will make your position a bit easier to understand.
Please take the time to document this, as I have done.

Don't take offense. Just prove your point.
This is extremely interesting, and I'd like to know
if you are actually right, because it would certainly
change the way I've understood, up until now,
the .NET Framework and ASP.NET's inner workings.


I'm not an MVP... :-p but this is just how it works. take a tour in
system.web.dll, in System.Web.Compilation through ildasm and you will
see some classes that does the parsing and compiling. probably there is
something in MSDN about this stuff.

I hope it helps to prove my point.

You can send me an email if you want. Just take the "-list" part off my
email.

[]'s

--------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

namespace ASP {
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;


[System.Runtime.CompilerServices.CompilerGlobalScop eAttribute()]
public class bla_aspx : System.Web.UI.Page, System.Web.SessionState.IRequiresSessionState {

private static int __autoHandlers;

private static bool __initialized = false;

private static System.Collections.ArrayList __fileDependencies;


#line 2 "D:\Root\bla.aspx"

void Page_Load(object sender, EventArgs e)
{
bla
}

#line default
#line hidden

public bla_aspx() {
System.Collections.ArrayList dependencies;
if ((ASP.bla_aspx.__initialized == false)) {
dependencies = new System.Collections.ArrayList();
dependencies.Add("D:\\Root\\bla.aspx");
ASP.bla_aspx.__fileDependencies = dependencies;
ASP.bla_aspx.__initialized = true;
}
this.Server.ScriptTimeout = 30000000;
}

protected override int AutoHandlers {
get {
return ASP.bla_aspx.__autoHandlers;
}
set {
ASP.bla_aspx.__autoHandlers = value;
}
}

protected System.Web.HttpApplication ApplicationInstance {
get {
return ((System.Web.HttpApplication)(this.Context.Applica tionInstance));
}
}

public override string TemplateSourceDirectory {
get {
return "/";
}
}

private void __BuildControlTree(System.Web.UI.Control __ctrl) {
}

protected override void FrameworkInitialize() {
this.__BuildControlTree(this);
this.FileDependencies = ASP.bla_aspx.__fileDependencies;
this.EnableViewStateMac = true;
this.Request.ValidateInput();
}

public override int GetTypeHashCode() {
return 5381;
}
}
}
--------------------------------------------------------------------------------

/t:library /utf8output /R:"c:\windows\microsoft.net\framework\v1.1.4322\ms corlib.dll" /R:"c:\windows\assembly\gac\system.enterpriseservic es\1.0.5000.0__b03f5f7f11d50a3a\system.enterprises ervices.dll" /R:"c:\windows\microsoft.net\framework\v1.1.4322\te mporary asp.net files\root\78f3146f\a4b7e5c9\assembly\dl2\d7d24fd5 \102994f1_06a6c401\chat2.dll" /R:"c:\windows\assembly\gac\system.data\1.0.5000.0_ _b77a5c561934e089\system.data.dll" /R:"c:\windows\assembly\gac\system.web.mobile\1.0.5 000.0__b03f5f7f11d50a3a\system.web.mobile.dll" /R:"c:\windows\assembly\gac\system.drawing\1.0.5000 .0__b03f5f7f11d50a3a\system.drawing.dll" /R:"c:\windows\assembly\gac\system.xml\1.0.5000.0__ b77a5c561934e089\system.xml.dll" /R:"c:\windows\assembly\gac\system.web.services\1.0 .5000.0__b03f5f7f11d50a3a\system.web.services.dll" /R:"c:\windows\assembly\gac\system\1.0.5000.0__b77a 5c561934e089\system.dll" /R:"c:\windows\assembly\gac\system.web\1.0.5000.0__ b03f5f7f11d50a3a\system.web.dll" /out:"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\ Temporary ASP.NET Files\root\78f3146f\a4b7e5c9\djudr-s0.dll" /D:DEBUG /debug+ /optimize- /warnaserror /w:1 "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temp orary ASP.NET Files\root\78f3146f\a4b7e5c9\djudr-s0.0.cs"

Nov 19 '05 #22
Juan T. Llibre [MVP] wrote:
I think we may be nearer to narrowing down
what is happening here.

That generated output is *not* the result of parsing and compiling
the page by ASP.NET, but the result of the csc.exe compiler
compiling the page, just as it would have been the result of the
vbc.exe compiler, if VB had been the language declared in the page.
Ok. Now think in what you said. Does it really make sense? "lets include
an html parser in the C# compiler"... i don't think so.

Yes, CSC compiles the code, but doesn't generates this class from html.
This is because it is specific to ASP.NET how it parses the page and
creates the class. CSC's job is just to compile C# code, nothing more.

There are some classes in .NET that generates code from xml, and this is
probaly generated by them. But who parses the html and generates the
input to this tool is ASP.NET. Because ASP.NET is responsible for this,
not CSC.
I have quite an interesting .NET/ASP.NET setup, because I'm running
Windows Server 2003, which includes .Net Framework 1.1 "out of the box",
which means I didn't have to install it.
Yes, because Win2003 comes with .NET 1.1.
I afterwards installed VS.NET 2005, which installed .Net Framework 2.0.

Here's the interesting thing :

I've *never* compiled any .NET 1.1.4322.2032 projects
( like for example, the ASP.NET Forums... ) with VS.NET 2005.
1.1.4322.2032 is the version of .NET 1.1 SP1, not VS.NET 2005.
Here's the key:

I did a search for source files ( .vb or .cs ) of the type which have the
"This code was generated by a tool" disclaimer, in the "Temporary
ASP.NET files"
folder, and *only* found files generated by VS.NET 2005 with this
disclaimer :

"This code was generated by a tool.
Runtime Version:2.0.40607.16"
So, here we go. Please, forget about VS.NET. .NET doesn't depend on
VS.NET to work. It is just a tool to help you create applications.

You got this because you installed .NET 2.0. After installing it, all
your asp.net pages are compiled with .net 2.0. You can change this in
your website properties in IIS.
I did *not* find any files with the disclaimer for "Runtime Version
1.1.4322.2032",
even though they were equally processed by ASP.NET.
Because it is processed by .NET 2.0 =)
This leads to the inescapable conclusion that it is *not*
ASP.NET which is compiling the .aspx files, as you claim,
and that it *is* the underlying compiler ( csc.exe or vbc.exe )
which is doing the compiling, the results of which *then* are
processed by aspnet_isapi.dll.
I can't understand how you got to this conclusion. "the numer is 2, not
1.. so csc is an html parser". this doesn't make sense.

What you discovered is that your code is generated by a different
version of the same tool, but you didn't see anything telling that csc
is parsin html pages.

When I tell you ASP.NET parses the page to generate the class, the real
process probably involves lots of classes in Microsoft.CSharp too. But
the one who parses the html and tell how to create the class is ASP.NET.
That is why you have System.Web.Compilation...
No. The aspx page is compiled by either csc.exe or vbc.exe,
depending on the language declared for the page, and ASP.NET
( aspnet_isapi.dll ) has nothing to do with the code until it processes
the MSIL generated by the appropiate compiler.


Of course it is compiled by csc. But not generated. That is why csc is
called "c sharp compiler" not "asp.net html parser".
Take a loot at this and this is probably how things work.
http://myxaml.com/marcclifton/archiv...04/21/223.aspx

so asp.net generates common input to some parser which given an language
type generates the real output. csc only compiles it.

[Tired...]
Nov 19 '05 #23
Natan,

Here's the sequence of events when an .aspx page is called:

1. Generation of a *.cs or .vb file holding code that matches the ASPX declarations.

2. Using of csc.exe (C# compiler) to compile *.cs file into DLL
or using of vbc.exe (VB.NET compiler) to compile *.vb file into DLL

You can see csc.exe or vbc.exe if you monitor the running processes
with Task Manager or any other process explorer. Try it, and see.

3. Running of the compiled page assembly

This sequence occurs just once, resulting in a DLL that will be used for other requests
until one of the page dependencies files are changed, leading to re-compilation.

Think of ASP.NET (aspnet_isapi.dll, w3wp.exe, aspnet_wp.exe, etc. ) as a "traffic policeman", directing the various components
of the .NET Framework which result in compiled pages but, please, don't think that ASP.NET compiles anything,
except in the loosest of interpretations.

The best explanation ( Dino Exposito's excellent article )
I've ever read about the ASP.NET HTTP Runtime is at :

http://msdn.microsoft.com/library/de...TTPRuntime.asp

Look for the subject heading : Temporary Files and Page Assemblies

And you'll see that it is "the HTTP infrastructure which parses the source code of the .aspx file,
creates a C# or Visual Basic .NET class (depending on the language set on the .aspx page),
and compiles it on the fly".

Dino explains the ASP.NET process splendidly in the heading:
*Components of the ASP.NET Infrastructure*

"The ASP.NET ISAPI extension is a Win32 DLL and does not host managed code.
It is the central console that receives and dispatches requests for a variety of ASP.NET resources. "

The specific .NET Framework class which handles reception and dispatch of requests is System.Web.HttpApplication,
called by the ASP.NET runtime environment ( aspnet_isapi.dll, aspnet_wp.exe, aspnet_filter.dll, and aspnet_state.exe for IIS 5,
and aspnet_isapi.dll, w3wp.exe, aspnet_filter.dll, and aspnet_state.exe for IIS 6. ).

It is the common language runtime (CLR) which runs managed code.

Even the simplest thing about ASP.NET, the recognition of an aspx request,
is handled by System.Web.UI.PageHandlerFactory ( a.NET Framework Class ),
and not by ASP.NET itself.

The aspx page parsing, which you insist is done by ASP.NET,
is actually carried out by System.Web.UI.PageParser, which is another ..NET Framework class.

ASP.NET neither parses nor compiles. It *calls* the appropiate .NET Framework classes and compilers.

Juan T. Llibre
===========
"Natan" <nv***@mandic.com.br> wrote in message news:Ow**************@TK2MSFTNGP14.phx.gbl...
Juan T. Llibre [MVP] wrote:
I think we may be nearer to narrowing down
what is happening here.



That generated output is *not* the result of parsing and compiling
the page by ASP.NET, but the result of the csc.exe compiler
compiling the page, just as it would have been the result of the
vbc.exe compiler, if VB had been the language declared in the page.


Ok. Now think in what you said. Does it really make sense? "lets include
an html parser in the C# compiler"... i don't think so.

Yes, CSC compiles the code, but doesn't generates this class from html.
This is because it is specific to ASP.NET how it parses the page and
creates the class. CSC's job is just to compile C# code, nothing more.

There are some classes in .NET that generates code from xml, and this is
probaly generated by them. But who parses the html and generates the
input to this tool is ASP.NET. Because ASP.NET is responsible for this,
not CSC.
I have quite an interesting .NET/ASP.NET setup, because I'm running
Windows Server 2003, which includes .Net Framework 1.1 "out of the box",
which means I didn't have to install it.


Yes, because Win2003 comes with .NET 1.1.
I afterwards installed VS.NET 2005, which installed .Net Framework 2.0.

Here's the interesting thing :

I've *never* compiled any .NET 1.1.4322.2032 projects
( like for example, the ASP.NET Forums... ) with VS.NET 2005.


1.1.4322.2032 is the version of .NET 1.1 SP1, not VS.NET 2005.
Here's the key:

I did a search for source files ( .vb or .cs ) of the type which have the
"This code was generated by a tool" disclaimer, in the "Temporary
ASP.NET files"
folder, and *only* found files generated by VS.NET 2005 with this
disclaimer :

"This code was generated by a tool.
Runtime Version:2.0.40607.16"


So, here we go. Please, forget about VS.NET. .NET doesn't depend on
VS.NET to work. It is just a tool to help you create applications.

You got this because you installed .NET 2.0. After installing it, all
your asp.net pages are compiled with .net 2.0. You can change this in
your website properties in IIS.
I did *not* find any files with the disclaimer for "Runtime Version
1.1.4322.2032",
even though they were equally processed by ASP.NET.


Because it is processed by .NET 2.0 =)
This leads to the inescapable conclusion that it is *not*
ASP.NET which is compiling the .aspx files, as you claim,
and that it *is* the underlying compiler ( csc.exe or vbc.exe )
which is doing the compiling, the results of which *then* are
processed by aspnet_isapi.dll.


I can't understand how you got to this conclusion. "the numer is 2, not
1.. so csc is an html parser". this doesn't make sense.

What you discovered is that your code is generated by a different
version of the same tool, but you didn't see anything telling that csc
is parsin html pages.

When I tell you ASP.NET parses the page to generate the class, the real
process probably involves lots of classes in Microsoft.CSharp too. But
the one who parses the html and tell how to create the class is ASP.NET.
That is why you have System.Web.Compilation...
No. The aspx page is compiled by either csc.exe or vbc.exe,
depending on the language declared for the page, and ASP.NET
( aspnet_isapi.dll ) has nothing to do with the code until it processes
the MSIL generated by the appropiate compiler.


Of course it is compiled by csc. But not generated. That is why csc is
called "c sharp compiler" not "asp.net html parser".


Take a loot at this and this is probably how things work.
http://myxaml.com/marcclifton/archiv...04/21/223.aspx

so asp.net generates common input to some parser which given an language
type generates the real output. csc only compiles it.

[Tired...]

Nov 19 '05 #24
Please, let`s make things clear...

First, we are talking about the same thing. And we agree in the same
points, there are no need for this debate.

Second, ASP.NET is the System.Web namespace. You said: "The aspx page
parsing, which you insist is done by ASP.NET, is actually carried out by
System.Web.UI.PageParser, which is another .NET Framework class."

You are right and I'm right. PageParser is a class in .NET as any other
class, but since everything inside System.Web namespace is related to
asp.net, when I say "asp.net parses the page", it is because there are
some classes in System.Web that handle all the processing of turning the
HTML code into code that is used to generate DLL.

And when I say "asp.net parses the aspx page" is different than "asp.net
compiles the page". All the parsing i'm talking about happens BEFORE
your item 1 finishes.

The rest of the processing is documented in .NET and what you said here
is exactly what i said before. Take a look at the previous messages and
you will see that what YOU said is that csc compiles the aspx page, and
i said the csc compiles the output that asp.net generates from the html
page. It is the same, you only jumped a few steps.

The problem here is that you think of ASP.NET as a bunch of dlls and
exes that IIS uses to talk to .NET while I think of ASP.NET as a
platform to delelop web applications using .NET, that includes not only
those files, but the whole System.Web namespace and everything related
that make things work. That'`s why you never agree with me and I never
agree with you.

I'm tired of the discussion. We are talking about the same thing, and
the original question has nothing to do with this discussion.

So let's top here. Think about my point of view, i think about yours and
we both learn a little bit ok?

[]`s
Nov 19 '05 #25
re:
ASP.NET is the System.Web namespace.
FWIW,

I think you're oversimplifying the picture.

If you believe that System.Web *is* ASP.NET, check out
http://www.csharpfriends.com/quickst...ace=System.Web
and see how much of ASP.NET is missing from the System.Web class

It's a *lot*.

If you think about ASP.NET more in terms of a "traffic cop",
processing requests and responses to the different components
of the whole platform, you'll be closer to the truth.

re: The problem here is that you think of ASP.NET
as a bunch of dlls and exes that IIS uses to talk to .NET
That's exactly what it is.

ASP.NET is an ISAPI application which sits between IIS
and the end user, and intercepts/requests/dispatches data
streams between them, calling components to process them.

The ASP.NET runtime environment is composed of only 4 parts :
aspnet_isapi.dll, aspnet_wp.exe, aspnet_filter.dll, and aspnet_state.exe for IIS 5,
and aspnet_isapi.dll, w3wp.exe, aspnet_filter.dll, and aspnet_state.exe for IIS 6.

The rest of the work is handled by the CLR, the .NET Framework and IIS.

re: i said the csc compiles the output that asp.net generates from the html page.
That's where the line becomes blurry.

ASP.NET does *not* "generate* anything.
It calls resources which do the generating, i.e. acts as the "traffic cop" alluded to earlier.

A fine line separates that from what you are saying...but it's a line nonetheless.

That having been said, this discussion has gone on long enough,
and we might be tiring the rest of the frequenters to this newsgroup.

If you feel the need to specify anything else, go ahead.

I've stated everything that I thought needed specifying.


Juan T. Llibre
===========
"Natan" <nv********@mandic.com.br> wrote in message news:ej**************@TK2MSFTNGP12.phx.gbl... Please, let`s make things clear...

First, we are talking about the same thing. And we agree in the same
points, there are no need for this debate.

Second, ASP.NET is the System.Web namespace. You said: "The aspx page
parsing, which you insist is done by ASP.NET, is actually carried out by
System.Web.UI.PageParser, which is another .NET Framework class."

You are right and I'm right. PageParser is a class in .NET as any other
class, but since everything inside System.Web namespace is related to
asp.net, when I say "asp.net parses the page", it is because there are
some classes in System.Web that handle all the processing of turning the
HTML code into code that is used to generate DLL.

And when I say "asp.net parses the aspx page" is different than "asp.net
compiles the page". All the parsing i'm talking about happens BEFORE
your item 1 finishes.

The rest of the processing is documented in .NET and what you said here
is exactly what i said before. Take a look at the previous messages and
you will see that what YOU said is that csc compiles the aspx page, and
i said the csc compiles the output that asp.net generates from the html
page. It is the same, you only jumped a few steps.

The problem here is that you think of ASP.NET as a bunch of dlls and
exes that IIS uses to talk to .NET while I think of ASP.NET as a
platform to delelop web applications using .NET, that includes not only
those files, but the whole System.Web namespace and everything related
that make things work. That'`s why you never agree with me and I never
agree with you.

I'm tired of the discussion. We are talking about the same thing, and
the original question has nothing to do with this discussion.

So let's top here. Think about my point of view, i think about yours and
we both learn a little bit ok?

[]`s

Nov 19 '05 #26
Juan T. Llibre [MVP] wrote:
I think you're oversimplifying the picture.


Whatever...
Nov 19 '05 #27
You are obviously referring to VS.Net. FYI, only after creating a
project does the web.config get created so it does not really make sense
to provide for default namespaces because the project would already have
been created by VS.Net.

with regards,
J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #28
Ravichandran J.V. wrote:
You are obviously referring to VS.Net. FYI, only after creating a


You obviously have no clue about what i`m talking about.
Nov 19 '05 #29
Hi Juan,
I think I should give a helping hand for Natan a bit here. The answers
that were provided are not helpful for Natan because he is looking for a way
to create aspx pages without the help of VS.NET , but the solutions provided
by the replies are all are for creating a VS.NET template which when used
will produce a skelital code page in the project.

Now to come to Natan, I dont think there is any option present as of yet for
ver 1.1 to have what you want Natan. I havent looked into v 2.0 yet, and if
they are bringing that functionality again, it sure is going to be a lot
useful.

Have a nice day.

Regards,
CC

"Juan T. Llibre [MVP]" wrote:
re:
Sorry, i respect you, but i won't explain again since you don't know
what i'm talking about. What i asked is written in the first post.


Nathan,

Your original question was :
Is there any way to automatically import more namespaces than
the default in aspx pages through some configuration in web.config?
I hate to keep all that <%@ Import Namespace="xxx" %> in all the pages...


The answer is *no*, you cannot do that via web.config,
at least not until .Net 2.0 is your Framework version.

Your original premise:
When you create and aspx page, this is generated by default:


using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Caching;
using System.Web.SessionState;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

is flawed, as you don't necessarily have to import
all those namespaces, and Notepad doesn't
"generate" anything like that.

In fact, Notepad doesn't generate anything.

In order to "generate" anything,
you must have been using VS.NET.

When I create a new C# Web Project,
the following classes are imported by default:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

That's a far cry from what you're
saying is imported by default.

Like I said, if you need more, or even less, classes
imported by default, in ASP.Net 1.0 or 1.1, if you're
using VS.NET 2002 or VS.NET 2003, the best
way to do it is to create a custom template for aspx pages.

Clearly, with Notepad you won't be able to do that,
but Notepad is your very particular pre-requisite.

For anybody else, using VS.NET 2002 or 2003,
creating a custom aspx template will do the job
neatly, for ASP.NET 1.0 or 1.1.

For anybody using VS.NET 2005 ( .Net Framework 2.0 )
one way to do it is to use the <imports> statement in
web.config, although doing that will generate excessive
memory usage.

The best way to do that in VS.NET 2005 is, still, to create
a Custom Web Form template which you can use for
individual pages, but not load the classes for all pages,
since that would, again, cause excessive memory consumption.

If you want to acknowledge that, fine.
If you don't want to acknowledge that, it's fine, too.

Let's move on, please.

Juan T. Llibre
===========

"Natan" <nv********@mandic.com.br> wrote in message news:%2****************@TK2MSFTNGP15.phx.gbl...
Juan T. Llibre [MVP] wrote:
re:
>Nothing to do with what i asked.

<sigh>

Would you please re-explain what it is you asked ?

( Particularly, how Notepad would "generate" what you want inserted ? )


Notepad doesn't generate anything, asp.net does.

Sorry, i respect you, but i won't explain again since you don't know
what i'm talking about. What i asked is written in the first post..

Nov 19 '05 #30

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by jean-marc | last post: by
1 post views Thread by Steve George | last post: by
5 posts views Thread by Christoffer | last post: by
4 posts views Thread by Kevin Newman | last post: by
11 posts views Thread by Connelly Barnes | last post: by
1 post views Thread by Arndt Jonasson | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.