Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Problem with ASP.NET Page Type discrepency.

Reply
Thread Tools

Problem with ASP.NET Page Type discrepency.

 
 
varnk
Guest
Posts: n/a
 
      03-12-2010
I am using Visual Studio 2008, ASP.NET 3.5 with Forms based authentication.

I have an ASP.NET page that is doing some strange things when I try to get
the type of the page through this.GetType() vs. typeof(MyPage).

For some reason, I am getting a different result for the type. When I use
typeof(), I get what I would expect, the actual type name with namespace
(MyNameSpace.Diagnostics). When I call GetType(), I get some type with a
strange name ASP.Confidential_MyNameSpace_Diagnostics. The two types seem to
not be the same. When I try to retrieve an attribute on the class (see code
below), it does not get my class attribute because of this type problem.
Can someone tell me how to remedy this? I need to use this.GetType()
because of some design constraints not shown in the sample.

See sample code below:

namespace MyNameSpace
{
[MyAttribute()]
public partial class Diagnostics : Page {
protected void Page_Load(object sender, EventArgs e) {
Type t1, t2;
object[] attr1, attr2;

t1 = this.GetType();
attr1 = t1.GetCustomAttributes(true); // This works - I Get
MyAttribute in the array

t2 = typeof(Diagnostics);
attr2 = t2.GetCustomAttributes(true); // This does not work.
No sign of MyAttribute in the array.
}
}
}

 
Reply With Quote
 
 
 
 
Adrienne Boswell
Guest
Posts: n/a
 
      03-13-2010
Gazing into my crystal ball I observed =?Utf-8?B?dmFybms=?=
<(E-Mail Removed)> writing in
news:(E-Mail Removed):

> I am using Visual Studio 2008, ASP.NET 3.5 with Forms based
> authentication.
>
> I have an ASP.NET page that is doing some strange things when I try to
> get the type of the page through this.GetType() vs. typeof(MyPage).
>
>


**********canned wrong newsgroup reply****************************
There was no way for you to know it (except maybe by browsing through
some of the previous questions before posting yours - always a
recommended practice), but this is a classic (COM-based) asp newsgroup.
ASP.Net is a different technology from classic ASP. While you may be
lucky enough to find a dotnet-savvy person here who can answer your
question, you can eliminate the luck factor by posting your question to
a newsgroup where the dotnet-savvy people hang out. I suggest

microsoft.public.dotnet.framework.aspnet.

There are also forums at www.asp.net where you can find a lot of people
to help you.
**********canned wrong newsgroup reply****************************


--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

 
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
type(d) != type(d.copy()) when type(d).issubclass(dict) kj Python 5 12-26-2010 06:48 PM
#define ALLOCIT(Type) ((Type*) malloc (sizeof (Type))) Yevgen Muntyan C Programming 10 02-13-2007 02:52 AM
Inheritance Problem from a simple base type to a structured complicated type mflll@wiu.edu XML 0 07-27-2006 12:26 AM
Re: Type casting- a larger type to a smaller type pete C Programming 4 04-02-2004 05:19 PM
Re: Type casting- a larger type to a smaller type heyo C Programming 3 04-01-2004 06:35 PM



Advertisments