确定已安装的 ASP.NET 主题
是否有一种简洁的编程方式来确定 ASP.NET 应用程序中安装了哪些主题?
我有几个 ASP.NET 应用程序,它们使用名称为“Theme”的 cookie 在 Page PreInit 事件中设置主题。 问题是,在我的开发环境中使用 localhost 时,一个应用程序的主题名称会呈现给另一个应用程序,从而引发异常:
在应用程序或全局主题目录中找不到主题“XYZ”。
我想我也许可以先检查我的应用程序有哪些主题,看看我要设置的内容是否有效 - 即无需查看 App_Themes 文件夹的内容。
Is there a neat programmatic way to determine which Themes are installed in an ASP.NET application?
I have several ASP.NET applications that use a cookie with the name of "Theme" to set the theme in the Page PreInit event. The trouble is, when using localhost in my development environment, the theme name for one application gets presented to another application and thereby throws the exception:
Theme 'XYZ' cannot be found in the application or global theme directories.
I thought I might be able to just check which themes my application has first to see if what I'm about to set is valid - that is without looking at the content of the App_Themes folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为如果不查看 App_Themes 文件夹就没有办法做到这一点。
但是您可以使用类似以下内容轻松列出现有主题:
或者检查给定主题是否存在:
I don't think there is a way to do this without looking at the App_Themes folder.
But you can easily list the existing themes, using something like this:
Or to check if a given theme exists: