Well, it has been quite a while since I talked about expression builders. If you haven’t already, I suggest you have a look at that, I think you will find interesting stuff there. Because I think this is an important topic for ASP.NET, I have two new expression builders for you:
|ThemeFileUrlExpressionBuilder||Returns a file URL relative to the current theme (/App_Themes/ThemeName)|
|WebResourceUrlExpressionBuilder||Returns the URL for an embedded resource file in the current or another assembly|
ThemeFileUrlExpressionBuilder may be useful when you have different themes (probably even switching them dynamically) and you want to reference a file that is relative to the current theme, without having it hardcoded.
As for WebResourceUrlExpressionBuilder, it retrieves the URL for a file included in an assembly as a web embedded resource.
As usual, the code first:
A typical usage would be:
You will have to register these expression builders on the Web.config file:
And you also have to register it with an assembly-level attribute, probably on AssemblyInfo.cs:
Of course, do replace MyNamespace and MyAssembly for your actual values. By the way, this is not specific to .NET 4, it will work from 2.0 upwards.
Looking forward to hearing from you!