PRB: Application Configuration File on Web Server Is Not Accessible When You Run Executable File in Internet Explorer (322086)



The information in this article applies to:

  • Microsoft .NET Framework 1.1
  • Microsoft .NET Framework 1.0

This article was previously published under Q322086

SYMPTOMS

In Microsoft Internet Explorer, if you run an executable file (EXE) that is located on a Web server, the EXE file cannot read the information from the associated application configuration file (.exe.config), although the configuration file is also located on the Web server.

CAUSE

When you have ASP.NET installed on your computer, ASP.NET handles all HTTP requests for configuration files. By default, ASP.NET is configured not to permit access to configuration files. Therefore, your EXE file is not permitted to gain access to the corresponding application configuration file.

Note The default configuration settings for your computer are stored in the machine configuration file (Machine.config). Machine.config is located in the following folder:

Windows Folder\Microsoft.NET\Framework\v1.1.4322\Config

RESOLUTION

To resolve this problem, change your configuration settings so that your EXE file is permitted to gain access to the application configuration file. To do this, follow these steps:
  1. In a text editor (such as Notepad), paste the following code:
    <configuration>
       <system.web>
          <httpHandlers>
             <remove verb="*" path="*.config"/>
             <add verb="*" path="Web.config" type="System.Web.HttpForbiddenHandler"/>
          </httpHandlers>
       </system.web>
    </configuration>
  2. Name the file Web.config, and then save it in the same folder as your EXE file.

    Important If the Web.config file already exists, add only the <httpHandlers> section to the existing Web.config file.
  3. In Internet Explorer, run your EXE file.
  4. Notice that the settings from the application configuration file are also used. For example, if you run MyApp.exe (you can create MyApp.exe by following the steps in the "More Information" section of this article), the following text appears in Internet Explorer:

    good day

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Visual Studio .NET, and then use Visual Basic .NET or Visual C# .NET to create a new Console Application named MyApp.
  2. Add the following code to Sub Main:

    Visual Basic .NET Sample Code
    System.Console.WriteLine("good " + System.Configuration.ConfigurationSettings.AppSettings("good"))
    System.Console.ReadLine()
    Visual C# .NET Sample Code
    System.Console.WriteLine("good " + System.Configuration.ConfigurationSettings.AppSettings["good"]);
    System.Console.ReadLine();
  3. In Solution Explorer, right-click your application name, point to Add, and then click Add New Item.
  4. Under Templates, click Application Configuration, and then click Open.
  5. Add the following application settings element in the <configuration> section:
       <appSettings>
          <add key="good" value="day"/>
       </appSettings>
  6. On the Build menu, click Build Solution.
  7. Copy the MyApp.exe file and the MyApp.exe.config file to the root folder of your Web Server.
  8. Start Internet Explorer, and then paste the following address in the Address bar:

    http://localhost/MyApp.exe

  9. Click Go. In Internet Explorer, only the following text appears:

    good

    Notice that day does not appear.

REFERENCES

For more information, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:5/20/2003
Keywords:KbhttpHandlers kbDownload kbConfig kbprb kbDeployment kbSecurity KB322086 kbAudDeveloper