Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. When is web.config called?

When is web.config called?

Scheduled Pinned Locked Moved .NET (Core and Framework)
comxmlquestionworkspace
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tripathi Swati
    wrote on last edited by
    #1

    I am not very sure of the exact answer. So, I am posting it to find the correct answer. But i guess Web.config is an xml configuration file. This never gets called directly unless we need to retrieve the configuration setting. I am not dam sure but i think this should happen.

    Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi

    J P 2 Replies Last reply
    0
    • T Tripathi Swati

      I am not very sure of the exact answer. So, I am posting it to find the correct answer. But i guess Web.config is an xml configuration file. This never gets called directly unless we need to retrieve the configuration setting. I am not dam sure but i think this should happen.

      Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi

      J Offline
      J Offline
      JHizzle
      wrote on last edited by
      #2

      Well...yes and no. It doesn't just hold your own configuration settings, it holds settings for the application so the file will automatically be read every time the application/application pool is restarted and is read into memory. Because of this, every time you change the web.config, the app will do a re-pre-compile to reread it into memory. So by rights, in ordinary use, it's only really called when the application is started. That being said, I've had to write custom web.config readers for specific projects but that's my custom code reading the physical file, not the normal operating procedure for the overall project.

      T 1 Reply Last reply
      0
      • J JHizzle

        Well...yes and no. It doesn't just hold your own configuration settings, it holds settings for the application so the file will automatically be read every time the application/application pool is restarted and is read into memory. Because of this, every time you change the web.config, the app will do a re-pre-compile to reread it into memory. So by rights, in ordinary use, it's only really called when the application is started. That being said, I've had to write custom web.config readers for specific projects but that's my custom code reading the physical file, not the normal operating procedure for the overall project.

        T Offline
        T Offline
        Tripathi Swati
        wrote on last edited by
        #3

        Thanks for your reply but i have one query so pls correct me if i m wrong This is how the minimal Web.config file should look like: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> </system.web> </configuration> I do agree that Web.config file is a perfect place to store ASP.NET application configuration settings but if i have above web.config then my other configuration must be in machine.config then how cum web.config called when application pool restarted. I may be wrong but pls give your glance and guide me ...

        Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi

        J N 2 Replies Last reply
        0
        • T Tripathi Swati

          Thanks for your reply but i have one query so pls correct me if i m wrong This is how the minimal Web.config file should look like: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> </system.web> </configuration> I do agree that Web.config file is a perfect place to store ASP.NET application configuration settings but if i have above web.config then my other configuration must be in machine.config then how cum web.config called when application pool restarted. I may be wrong but pls give your glance and guide me ...

          Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi

          J Offline
          J Offline
          JHizzle
          wrote on last edited by
          #4

          Because as far as I know, you cannot stop a web application from checking web.config. Just because it's empty is no reason for it not to still read it into memory. This is inbuilt behaviour as far as I know. I also wouldn't use machine.config to hold settings for you. If you are concerned about security, you can encrypt sections of the web.config and the .NET service will decrypt it automatically for you so you don't even need to chagne your code.

          T 1 Reply Last reply
          0
          • J JHizzle

            Because as far as I know, you cannot stop a web application from checking web.config. Just because it's empty is no reason for it not to still read it into memory. This is inbuilt behaviour as far as I know. I also wouldn't use machine.config to hold settings for you. If you are concerned about security, you can encrypt sections of the web.config and the .NET service will decrypt it automatically for you so you don't even need to chagne your code.

            T Offline
            T Offline
            Tripathi Swati
            wrote on last edited by
            #5

            ohhkkk Thanks for your reply now i am clear with my question actually i was confused just because of machine.config. Thanks once again for your reply.

            Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi

            1 Reply Last reply
            0
            • T Tripathi Swati

              Thanks for your reply but i have one query so pls correct me if i m wrong This is how the minimal Web.config file should look like: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.web> </system.web> </configuration> I do agree that Web.config file is a perfect place to store ASP.NET application configuration settings but if i have above web.config then my other configuration must be in machine.config then how cum web.config called when application pool restarted. I may be wrong but pls give your glance and guide me ...

              Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              http://msdn.microsoft.com/en-us/library/aa719558(VS.71).aspx[^] Multiple configuration files, all named Web.config, can appear in multiple directories on an ASP.NET Web application server. Each Web.config file applies configuration settings to its own directory and all child directories below it. Configuration files in child directories can supply configuration information in addition to that inherited from parent directories, and the child directory configuration settings can override or modify settings defined in parent directories. The root configuration file named systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Machine.config provides ASP.NET configuration settings for the entire Web server.


              I know the language. I've read a book. - _Madmatt

              1 Reply Last reply
              0
              • T Tripathi Swati

                I am not very sure of the exact answer. So, I am posting it to find the correct answer. But i guess Web.config is an xml configuration file. This never gets called directly unless we need to retrieve the configuration setting. I am not dam sure but i think this should happen.

                Reasons are not Important but Results are Important. http://www.sql4professional.blogspot.com Swati Tripathi

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                My understanding (from reading a WCF book) is that web.config is used by IIS when it runs your application. Your application is basically a plug-in that IIS runs if it has been configured to do so. I would put my own configuration information somewhere else.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups