I've a couple of email templates and I would like to store each in a sepparate file. I'd like to avoid having to read them from disc everytime I need them. Is there any built in structure in ASP.NET that automatically loads them when needed and shares this resources throughout the application?
You can use the Cache
or Application
objects.
Also, for simple tasks, a simple static
field would suffice.
You can create a Global_Resources folder in your web app and put global resources files there. (*.resx files)
ASP.NET Caching is good for your problem.
Also you can use Enterprise Library Caching Block.
You can store the email in the Application Dictionary or in the cache or in resource files but in the long run I have found that depending on the size of the file, the amount of files and the frequency of use it is often best to just read it from the disk every time. This way you do not clog memory and you do not have to have any caching code.
If the file is small and you only need it every now and then just read it from the disk. If you only have a few templates and you need them all the time then go with one of the other suggestions. (if the templates are plain text I would use the resource files and not reinvent the wheel, but if you need complex templates you may want something else)