Reputation: 2899
I have an AngularJS project in "empty" type .net project, which is hosted on IIS with .Net 4.0 framework. I basically don't use any .net dlls but since the project has a web.config file i add some App setting to use in the project. Trying to set development/production setting.
Is there a way to access AppSettings in the .net web.config file from AngularJS, because i am not using a MVC project, I can't use razor (@System.Configuration.ConfigurationManager.AppSettings["url"]).
Is there another way to this?
Thanks
Upvotes: 1
Views: 7116
Reputation: 269
You may want to expose a WebApi controller or MVC controller that returns JSON that represents web.config file... or at least the JSON object that has the data in the web.config file you need to send to client. The WebApi controller would read from web.config via configuration manager, convert to JSON, and send to client.
I am doing something similar where I am storing my service endpoints that my angular app needs in my web.config, but I want to transform the .config files based upon debug, dev, staging, production etc.
Upvotes: 4
Reputation: 11095
You don't.
The Web.Config file is a server-side configuration file, AngularJS is a client-side framework.
You can't access it from the browser, because IIS will never - for security reasons - serve it to clients.
Upvotes: 8