How to obtain the ASP.NET Core application name?

serge picture serge · Jul 24, 2017 · Viewed 8.7k times · Source

I would like do display in the footer of an ASP.NET Core 1.1

© 2017 MyApplication

<p>&copy; 2017 @(ApplicationName)</p>

How do I get the application name?

I found an article on this subject but it's confusing about PlatformServices.Default.Application.ApplicationName, because it says do not use Microsoft.Extensions.PlatformAbstractions, but does not say what to use instead for the application name...

Answer

Duran Hsieh picture Duran Hsieh · Jul 25, 2017

You could try:

@using System.Reflection;
<!DOCTYPE html>
<html>
 ....

    <footer>
        <p>&copy; 2017 - @Assembly.GetEntryAssembly().GetName().Name</p>
    </footer>
</html>

I am not sure it is a good way, but it works for me :)

enter image description here