Access to the web.config file in a third-party library

I am writing IHttpFilter, which should be in a separate project (these are all C # projects), which will be used in the ASP.NET MVC application suite. In IHttpFilter, I have to define a few things that are specified in the web.config file.

Is there a way to get the current web.config file from an external assembly at runtime? There are three settings I need to get (strings).

Another problem is that I need to reference a bunch of files (images), but I'm not sure whether to place it in an ASPp MVC application or in an IHttpHandler project.

+3
source share
2 answers

, , , -.

- , , - - web.config. IHttpHandler.

, , , , , , -. web.config.

: Ive, , Ive , , . bin -, , , .

, -.

0

, , web.config :

var configFile = new FileInfo(configPath);

WebConfigurationFileMap map = new WebConfigurationFileMap();

var appBase = 
    new VirtualDirectoryMapping(configFile.DirectoryName, true, configFile.Name);
map.VirtualDirectories.Add("/", appBase);

return WebConfigurationManager.OpenMappedWebConfiguration(map, "/");

configPath - , web.config.

0

Source: https://habr.com/ru/post/1718792/


All Articles