Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Finding all Web Forms in a web site using reflection

Reply
Thread Tools

Finding all Web Forms in a web site using reflection

 
 
Per Bolmstedt
Guest
Posts: n/a
 
      12-14-2006
(This question has been asked previously in this group, but I don't
think it was ever really properly answered.)

I want to use reflection - preferably - to find all Web Forms in my web
site that inherit my base page class (which in turn inherits
System.Web.UI.Page). Behold the following code:

For Each asm As System.Reflection.Assembly In
System.AppDomain.CurrentDomain.GetAssemblies()
For Each mdl As System.Reflection.Module In asm.GetModules()
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassOf(GetType(MyBasePage))
..

This code only seems to list Web Forms that have actually been run. Why
is that? Even pages within the same assembly don't show up until they
have been run. Also, this behaviour is the same in the ASP.NET
Development Server and a web site published with the ASP.NET compiler
running in IIS.

Is there another, better, way to find a list of all Web Forms in a web
site?

I want to avoid having to inspect all DLL files in ~/bin/...

 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      12-14-2006
Are you using the typical ASP.Net Web Site project, or are you using the
add-on Web Application project. I don't think the Web Site project forms are
truly getting pre-compiled in the same fashion that the Web Application
project or the old VS 2003 web projects did. You might experiment by
creating an app with the new web application project download over at
www.asp.net and see if there is a difference. I stopped using the web site
project for similar compilation issues.


--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006




"Per Bolmstedt" <> wrote in message
news: ps.com...
> (This question has been asked previously in this group, but I don't
> think it was ever really properly answered.)
>
> I want to use reflection - preferably - to find all Web Forms in my web
> site that inherit my base page class (which in turn inherits
> System.Web.UI.Page). Behold the following code:
>
> For Each asm As System.Reflection.Assembly In
> System.AppDomain.CurrentDomain.GetAssemblies()
> For Each mdl As System.Reflection.Module In asm.GetModules()
> For Each typ As System.Type In mdl.GetTypes()
> If typ.IsSubclassOf(GetType(MyBasePage))
> ..
>
> This code only seems to list Web Forms that have actually been run. Why
> is that? Even pages within the same assembly don't show up until they
> have been run. Also, this behaviour is the same in the ASP.NET
> Development Server and a web site published with the ASP.NET compiler
> running in IIS.
>
> Is there another, better, way to find a list of all Web Forms in a web
> site?
>
> I want to avoid having to inspect all DLL files in ~/bin/...
>



 
Reply With Quote
 
 
 
 
Per Bolmstedt
Guest
Posts: n/a
 
      12-14-2006

It's a normal "ASP.NET Web Site" created with VS2005.

I don't think precompilation is the issue since the behaviour exhibits
on a "published" web site as well.

The merge tool in the WAP template would probably let me reflect the
way I want, but I'd still be interested in explanations of the
behaviour, as well as possible solutions for an ASP.NET Web Site...

On Dec 14, 2:36 pm, "Mark Fitzpatrick" <markf...@fitzme.com> wrote:
> Are you using the typical ASP.Net Web Site project, or are you using the
> add-on Web Application project. I don't think the Web Site project forms are
> truly getting pre-compiled in the same fashion that the Web Application
> project or the old VS 2003 web projects did. You might experiment by
> creating an app with the new web application project download over atwww.asp.netand see if there is a difference. I stopped using the web site
> project for similar compilation issues.
>
> --
>
> Hope this helps,
> Mark Fitzpatrick
> Former Microsoft FrontPage MVP 199?-2006
>
> "Per Bolmstedt" <tom...@gmail.com> wrote in messagenews: glegroups.com...
>
> > (This question has been asked previously in this group, but I don't
> > think it was ever really properly answered.)

>
> > I want to use reflection - preferably - to find all Web Forms in my web
> > site that inherit my base page class (which in turn inherits
> > System.Web.UI.Page). Behold the following code:

>
> > For Each asm As System.Reflection.Assembly In
> > System.AppDomain.CurrentDomain.GetAssemblies()
> > For Each mdl As System.Reflection.Module In asm.GetModules()
> > For Each typ As System.Type In mdl.GetTypes()
> > If typ.IsSubclassOf(GetType(MyBasePage))
> > ..

>
> > This code only seems to list Web Forms that have actually been run. Why
> > is that? Even pages within the same assembly don't show up until they
> > have been run. Also, this behaviour is the same in the ASP.NET
> > Development Server and a web site published with the ASP.NET compiler
> > running in IIS.

>
> > Is there another, better, way to find a list of all Web Forms in a web
> > site?

>
> > I want to avoid having to inspect all DLL files in ~/bin/...


 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      12-14-2006
reflection can only see loaded assemblies. in asp.net each page is a
seperate dll (though using batching can cause some grouping). each page
dll gets loaded the first time its referenced. if the site is not
precompiled, the dll don't even exist until the page is requested
(always true in version 1).

in 1.1 the code-behinds were compiled into one dll (by vs), so
reflection could see the base classes for web pages, but the actual page
class was not available until the actual page dll was loaded.


-- bruce (sqlwork.com)


Per Bolmstedt wrote:
> (This question has been asked previously in this group, but I don't
> think it was ever really properly answered.)
>
> I want to use reflection - preferably - to find all Web Forms in my web
> site that inherit my base page class (which in turn inherits
> System.Web.UI.Page). Behold the following code:
>
> For Each asm As System.Reflection.Assembly In
> System.AppDomain.CurrentDomain.GetAssemblies()
> For Each mdl As System.Reflection.Module In asm.GetModules()
> For Each typ As System.Type In mdl.GetTypes()
> If typ.IsSubclassOf(GetType(MyBasePage))
> ..
>
> This code only seems to list Web Forms that have actually been run. Why
> is that? Even pages within the same assembly don't show up until they
> have been run. Also, this behaviour is the same in the ASP.NET
> Development Server and a web site published with the ASP.NET compiler
> running in IIS.
>
> Is there another, better, way to find a list of all Web Forms in a web
> site?
>
> I want to avoid having to inspect all DLL files in ~/bin/...
>

 
Reply With Quote
 
Per Bolmstedt
Guest
Posts: n/a
 
      12-14-2006

I'm using ASP.NET 2.0 and the ASP.NET Web Site template, so none of
this applies. Rather, each ASP.NET directory gets compiled into its own
App_Web_????????.dll assembly. But "pages" (classes that inherit a
class that inherits System.Web.UI.Page) in the same assembly don't show
up in the sample reflection code below unless they're explicitly
invoked, which I find odd.

But I guess the WAP template is the only real solution. Can anyone
verify that it does indeed solve my problem?

On Dec 14, 5:21 pm, bruce barker <nos...@nospam.com> wrote:
> reflection can only see loaded assemblies. in asp.net each page is a
> seperate dll (though using batching can cause some grouping). each page
> dll gets loaded the first time its referenced. if the site is not
> precompiled, the dll don't even exist until the page is requested
> (always true in version 1).
>
> in 1.1 the code-behinds were compiled into one dll (by vs), so
> reflection could see the base classes for web pages, but the actual page
> class was not available until the actual page dll was loaded.
>
> -- bruce (sqlwork.com)
>
> Per Bolmstedt wrote:
> > (This question has been asked previously in this group, but I don't
> > think it was ever really properly answered.)

>
> > I want to use reflection - preferably - to find all Web Forms in my web
> > site that inherit my base page class (which in turn inherits
> > System.Web.UI.Page). Behold the following code:

>
> > For Each asm As System.Reflection.Assembly In
> > System.AppDomain.CurrentDomain.GetAssemblies()
> > For Each mdl As System.Reflection.Module In asm.GetModules()
> > For Each typ As System.Type In mdl.GetTypes()
> > If typ.IsSubclassOf(GetType(MyBasePage))
> > ..

>
> > This code only seems to list Web Forms that have actually been run. Why
> > is that? Even pages within the same assembly don't show up until they
> > have been run. Also, this behaviour is the same in the ASP.NET
> > Development Server and a web site published with the ASP.NET compiler
> > running in IIS.

>
> > Is there another, better, way to find a list of all Web Forms in a web
> > site?

>
> > I want to avoid having to inspect all DLL files in ~/bin/...


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List of free web site design, web site backgrounds, web site layoutsresources cyber XML 1 12-25-2007 11:48 PM
List of free web site design, web site backgrounds, web site layoutsresources cyber HTML 0 12-21-2007 03:47 PM
List of free web site design, web site backgrounds, web site layoutsweb sites cyber HTML 1 12-19-2007 09:07 AM
Finding Controls in a page using System.Reflection =?Utf-8?B?Z25hbmE=?= ASP .Net 1 04-04-2006 07:06 PM
wihout using java reflection api finding the properties of a class ravi Java 3 02-08-2006 11:40 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57