Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6322797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:23:57+00:00 2026-05-24T16:23:57+00:00

I’ve create a method that gets the current page’s assembly name and version so

  • 0

I’ve create a method that gets the current page’s assembly name and version so that I can display it in the page footer. It works just fine, but I’d like to move this logic into a control that I could drop into any web application project master page that references my control library. However, in the control library Assembly.GetExecutingAssembly() returns the control library assembly, not the web project assembly.

Here’s the method:

    private string GetVersion()
    {
        const string cacheKey = "Web.Controls.ApplicationVersion";
        string version = (string) Page.Cache[cacheKey];
        if (version == null)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();

            // get the assembly version
            Version assemblyVersion = assembly.GetName().Version;

            // get the product name
            string productName;
            AssemblyProductAttribute productAttribute =
                assembly.GetCustomAttributes(typeof (AssemblyProductAttribute), false).Cast
                    <AssemblyProductAttribute>().FirstOrDefault();
            if (productAttribute != null)
            {
                productName = productAttribute.Product;
            }
            else
            {
                productName = String.Empty;
            }

            version = String.Format("{0} {1}", productName, assemblyVersion);

            Page.Cache[cacheKey] = version;
        }

        return version;
    }

I’ve also tried Assembly.GetEntryAssembly() which returns null, and Assembly.GetCallingAssembly() which returns the control assembly. Finally I tried Assembly.GetAssembly(Page.GetType()), which returns the page type generated at runtime (ASP.abc).

How can I get the web project assembly from within the context of a Control without asking for it explicitly by name?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:23:58+00:00Added an answer on May 24, 2026 at 4:23 pm

    maybe it is not in time. But today I had run into the same issue. And first what I had found was your questions without answer ( . Later I digged around this question.
    The answer is: Assembly.GetAssembly(Page.GetType().BaseType)

    The reason is generation page type at runtime as you mentioned above.
    Good explanation I found in MSDN:

    The type of the HTTP handler for a particular page depends on the URL.
    The first time the URL is invoked, a new class is composed and
    dynamically compiled to an assembly. The source code of the class is
    the outcome of a parsing process that examines the .aspx sources. The
    class is defined as part of the namespace ASP and is given a name that
    mimics the original URL. For example, if the URL endpoint is
    page.aspx, the name of the class is ASP.Page_aspx. The class name,
    though, can be programmatically controlled by setting the ClassName
    attribute in the @Page directive.

    The base class for the HTTP handler is Page. This class defines the
    minimum set of methods and properties shared by all page handlers. The
    Page class implements the IHttpHandler interface.

    Under a couple of circumstances, the base class for the actual handler
    is not Page but a different class. This happens, for example, if
    code-behind is used. Code-behind is a development technique that
    insulates the code necessary to a page into a separate C# or Microsoft
    Visual Basic® .NET class. The code of a page is the set of event
    handlers and helper methods that actually create the behavior of the
    page. This code can be defined inline using the
    tag or placed in an external class—the code-behind class. A
    code-behind class is a class that inherits from Page and specializes
    it with extra methods. When specified, the code-behind class is used
    as the base class for the HTTP handler.

    So when you are using Page.GetType() you will get dynamic composed class. And this class is inherited from actual page class, and this one is into project assembly.
    http://msdn.microsoft.com/en-us/library/aa479007.aspx -MSDN article refference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I'm making a simple page using Google Maps API 3. My first. One marker
In order to apply a triggered animation to all ToolTip s in my app,
Seemingly simple, but I cannot find anything relevant on the web. What is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.