how to read config file in IISModule?

mc 4,086 Reputation points

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 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) 5,237 Reputation points Microsoft Employee

    IIS API only standardizes access to IIS XML configuration, which ASP.NET Core module or HttpPlatformHandler v2 relies on

    If you can follow the same convention to define parameters of your module, then you reuse 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 must 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,286 Reputation points Microsoft Vendor


    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.