Search code examples
blazorblazor-webassemblymudblazor

How to access appinfo in mudblazor layout


I am working on blazor application where I have to show my app info and app build version below the html Lang tag. But the appinfo is not accessible over layout.

I have tried to access it through by adding @app.utilities but it's giving error only one namespace can be used.

Second I have tried to access using @app.utilities but it's not accessible too


Solution

  • Your question is pretty vague, but my simple example should should point you in the right direction. I'd imagine all the information you're searching for will be available somewhere in the assembly.

    @using System.Reflection
    
     <MudContainer MaxWidth="MudBlazor.MaxWidth.ExtraExtraLarge" Class="my-1">
     @Body
     @GetVersion()
     </MudContainer>
    
    @code
    {
        public string GetVersion()
        {
            var assembly = Assembly.GetExecutingAssembly();
            return assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion ?? "[Unknown]";
        }
    }