I have a fair sized config file in my asp.net application that I would to have access to in my client side script. Can anyone think of a good way to cause a section of my configuration to be serialized out as JSON and made available as a cacheable url? this is .net 3.5, and the config doesnt have any security issues.
A:
If your referring to the web.config I'm certain you cannot access it via URL. This is a native ASP.Net security feature. You would want to create a custom config in a secure location and read/update it via AJAX using a server-side mechanism such as an IHttpHandler.
pixelbobby
2009-09-28 20:37:24
IHttpHandler would seem to be the right approach, especially as I use something similar to get my compressed css.
BozoJoe
2009-09-29 00:45:18
hey, glad to help :)
pixelbobby
2009-09-29 14:48:12
no more answers, you win pixelboy
BozoJoe
2009-10-06 01:02:34
A:
I have not yet tried this approach but I am sure you will find it useful. You can use T4 Templates to build a class dynamically from the config sections. This means anytime you change anything in that config section it will be picked up by the T4 templates and available for use in intellisense.
For a brief introduction on T4 templates check out the following URL:
http://highoncoding.com/Articles/557%5FCode%5FGeneration%5FUsing%5FT4%5FTemplates.aspx
azamsharp
2009-09-28 22:17:51