I would like to read the configuration file in the relative path from the current folder on several web programs at asp.net in C#.
For example folder configuration below, I would like to be able to see aaa.xml of A app from the event of A app, and aaa.xml of B app from the event of B app.
IIS root folder <
AA Application ProProperties aaaa.xml
BB app ProProperties aaaa.xml
Is there a way to make it possible?
.NET is 4.6.2
The IIS operating server is Windows Server 2016.
For IIS+.NET Framework, use MapPath.
Specifies the relative path from the web root, not from the current folder
.
string fullpath=Request.MapPath("~/config/aaa.config");
~/
will be replaced by the IIS root folder AA app
in the top directory of the application.
If you have configured a virtual path in the IIS Management Console, you can view the real folder that corresponds to that virtual path.
IIS should be careful to avoid accidents where the configuration file is unexpectedly visible to the outside world.
I think the extension of the configuration file should be .config
, not .xml
.
IIS defaults to allow and deny HTTP access with extensions.
Even if you forget the per-folder deny setting, if the extension denies it, you can prevent the files from being viewed incorrectly from the outside.
599 GDB gets version error when attempting to debug with the Presense SDK (IDE)
568 Who developed the "avformat-59.dll" that comes with FFmpeg?
607 Uncaught (inpromise) Error on Electron: An object could not be cloned
886 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.