Problem with ASP.NET Page Type discrepency.

Discussion in 'ASP General' started by varnk, Mar 12, 2010.

  1. varnk

    varnk Guest

    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.
    }
    }
    }
    varnk, Mar 12, 2010
    #1
    1. Advertising

  2. Gazing into my crystal ball I observed =?Utf-8?B?dmFybms=?=
    <> writing in
    news::

    > 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
    Adrienne Boswell, Mar 13, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. heyo
    Replies:
    3
    Views:
    884
    Dan Pop
    Apr 1, 2004
  2. pete
    Replies:
    4
    Views:
    779
    Dan Pop
    Apr 2, 2004
  3. Yevgen Muntyan

    #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type)))

    Yevgen Muntyan, Feb 9, 2007, in forum: C Programming
    Replies:
    10
    Views:
    879
    Yevgen Muntyan
    Feb 13, 2007
  4. JimLewis
    Replies:
    2
    Views:
    603
    karl bezzoto
    Nov 26, 2009
  5. Glen Rice

    struct calcsize discrepency?

    Glen Rice, Dec 4, 2011, in forum: Python
    Replies:
    9
    Views:
    236
    Nobody
    Dec 6, 2011
Loading...

Share This Page