Identify installed ASP.NET themes

Is there a clear programmatic way to determine which themes are installed in an ASP.NET application?

I have several ASP.NET applications that use a cookie called "Theme" to set the theme in a PreInit event. The problem is that when using localhost in my development environment, the theme name for one application is displayed in another application and thus throws an exception:

The theme "XYZ" cannot be found in application directories or global themes.

It seemed to me that I could just check what themes my application has, first of all, to check if what I'm going to install is really not looking at the contents of the App_Themes folder.

+3
source share
1 answer

I don’t think there is a way to do this without looking at the App_Themes folder.

But you can easily list existing topics using something like this:

DirectoryInfo themes = new DirectoryInfo(Server.MapPath("~/App_Themes"));
foreach (DirectoryInfo theme in themes.GetDirectories())
{
    string themeName = theme.Name;
}

Or check if this topic exists:

Directory.Exists(Server.MapPath("~/App_Themes/" + theTheme))
+5
source

Source: https://habr.com/ru/post/1715072/


All Articles