how to read config file in IISModule?

mc 3,906 Reputation points
2024-06-19T12:28:52.6+00:00

how to read txt or other config file in IIS Module? it seems can not read txt file there is no permission to read any file.in the dll file I can not read the config file.(not read each website but one file)

I put it in inetmgr1 folder or local folder can not read it.

Internet Information Services
{count} votes

Accepted answer
  1. Lex Li (Microsoft) 4,987 Reputation points Microsoft Employee
    2024-06-20T04:17:31.2466667+00:00

    IIS API only standardizes access to IIS XML configuration, which ASP.NET Core module or HttpPlatformHandler v2 relies on https://github.com/lextudio/httpplatformhandlerv2/blob/httpplatformhandler_v8.0.3-rc.2/src/Servers/IIS/AspNetCoreModuleV2/IISLib/ahutil.h

    If you can follow the same convention to define parameters of your module, then you use the same code.

    If you, however, want to use your own config file, .txt or .ini, then this question has little to do with IIS, but general Windows C/C++ programming. You might use the standard C/C++ file IO API to read files at will, but of course pay attention to the actual user account that executes your code to ensure file access permissions are granted.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sam Wu-MSFT 7,131 Reputation points Microsoft Vendor
    2024-06-20T03:28:40.4733333+00:00

    @mc

    IIS Module does not have the function of reading files, a module is either a Win32 DLL (native module) or a . NET 2.0 type contained within an assembly (managed module). Similar to a set of building blocks, modules are added to the server in order to provide the desired functionality for your applications.

    If you want to read config file, you can try to use code to read the config file, which is usually located in the %WinDir%\System32\Inetsrv\Config folder


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.