473,756 Members | 6,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding all Web Forms in a web site using reflection

(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.P age). Behold the following code:

For Each asm As System.Reflecti on.Assembly In
System.AppDomai n.CurrentDomain .GetAssemblies( )
For Each mdl As System.Reflecti on.Module In asm.GetModules( )
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassO f(GetType(MyBas ePage))
..

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/...

Dec 14 '06 #1
4 2194
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" <to****@gmail.c omwrote in message
news:11******** *************@f 1g2000cwa.googl egroups.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.P age). Behold the following code:

For Each asm As System.Reflecti on.Assembly In
System.AppDomai n.CurrentDomain .GetAssemblies( )
For Each mdl As System.Reflecti on.Module In asm.GetModules( )
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassO f(GetType(MyBas ePage))
..

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/...

Dec 14 '06 #2

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...@fitzm e.comwrote:
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.netan d 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.c omwrote in messagenews:11* *************** *****@f1g2000cw a.googlegroups. 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.P age). Behold the following code:
For Each asm As System.Reflecti on.Assembly In
System.AppDomai n.CurrentDomain .GetAssemblies( )
For Each mdl As System.Reflecti on.Module In asm.GetModules( )
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassO f(GetType(MyBas ePage))
..
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/...
Dec 14 '06 #3
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.P age). Behold the following code:

For Each asm As System.Reflecti on.Assembly In
System.AppDomai n.CurrentDomain .GetAssemblies( )
For Each mdl As System.Reflecti on.Module In asm.GetModules( )
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassO f(GetType(MyBas ePage))
..

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/...
Dec 14 '06 #4

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.P age) 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. comwrote:
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.P age). Behold the following code:
For Each asm As System.Reflecti on.Assembly In
System.AppDomai n.CurrentDomain .GetAssemblies( )
For Each mdl As System.Reflecti on.Module In asm.GetModules( )
For Each typ As System.Type In mdl.GetTypes()
If typ.IsSubclassO f(GetType(MyBas ePage))
..
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/...
Dec 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1246
by: Jaime Lucci | last post by:
Hi, how've you been? I'm trying to do a .dll that would be able to manage forms from an independient project. The dll has a method that receive a parameter which is the form I want to manage. The problem is that I have to pass the instancied form as parameter instead of its name. When I have to manage many forms, it will be necessary to instance all forms, and it minus the performance of my project. What I do is:
3
4372
by: Bisbal | last post by:
Hi, I'd like to know if it is possible to create a form type from a string. My case: I have a DataTable with forms names (i.e frm_001_UserInfo.cs), and I'd like to create an instance of that form from my code dynamically, retrieving the form name from the database. Something like str = "frm_001_UserInfo.cs" and then create an instance of the form using str.
6
1227
by: JonS. | last post by:
Hi, I'm trying to create a Windows Forms portal application and need some help. What I currently have is a main application (.exe) containing an MDI form. The idea is that this main application loads forms from packages (i.e. DLLs containing one or more forms). The trick is that I'd like the form packages and forms loaded to be dynamic. Therefore the main application should be able to "discover" all the form packages, then allow those...
0
4247
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET Applications and owner of Access Microsystems. Doug can be reached at doug@accessmicrosystems.com. --------------------------------------------------------------------------------
6
1088
by: Tor Inge Rislaa | last post by:
Finding name of all forms I want to create a procedure that can loop trough all objects of type form in an application and print the name property to the debug window. TIRislaa
8
7939
by: J.S. | last post by:
I was under the impression that frames could be used in Windows forms in earlier version of VB. However, in VB 2005 Express I don't see any such tool/control. Is SplitContainer used for this purpose in VB 2005? I want to create a frame in a Windows form because I'd like button clicks on the left side of the form to change the form elements shown in the right side of the form. Would each of the buttons on the left require a...
12
1973
by: Peter Van Wilrijk | last post by:
Hi, In VB6 I have the following code ... Dim frmLink As Form Set frmLink = Forms.Add(stringformname) frmLink.Show 'wait until all data has been loaded Do Until frmLink.Loaded = 21 DoEvent
1
2045
by: gnana | last post by:
Hi, I want to find controls in a ASP.NET page using System.Reflection.Assembly. I have to create an Application to set the Permission(visible/editable) for each control on the page, for this i need to know what are the controls in a asp.NET page. All I have is Assembly (.DLL) and page name. Please help me. Thanks!
7
1695
by: joproulx | last post by:
Hi, I was wondering if there was a way with Reflection to find dynamically if an object was referencing indirectly another object. A simple example would be: Object1 | --Object2 |
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.