Connection String: Global.asax vs. web.config file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • D. Shane Fowlkes

    Connection String: Global.asax vs. web.config file

    Upon reading through my ASP.NET book, I've learned how to place the
    connection string in both locations in my application. Just due to habit, I
    naturally want to place my SQL Server connection string in the asax
    file...but are there really advantages to having in one file over the other?

    Thanks


  • Steve C. Orr [MVP, MCSD]

    #2
    Re: Connection String: Global.asax vs. web.config file

    Your web.config file is generally considered a better place because it's a
    simple text file that is easily updated without needing to recompile
    anything and changes go into effect immediately.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP

    Hire top-notch developers at http://www.able-consulting.com



    "D. Shane Fowlkes" <shanefowlkes @h-o-t-m-a-i-l.com> wrote in message
    news:%23n0KceT2 DHA.1744@TK2MSF TNGP12.phx.gbl. ..[color=blue]
    > Upon reading through my ASP.NET book, I've learned how to place the
    > connection string in both locations in my application. Just due to habit,[/color]
    I[color=blue]
    > naturally want to place my SQL Server connection string in the asax
    > file...but are there really advantages to having in one file over the[/color]
    other?[color=blue]
    >
    > Thanks
    >
    >[/color]


    Comment

    • Jeremy

      #3
      Re: Connection String: Global.asax vs. web.config file

      I agree.

      I use the web.config file because in our environment I
      have to move an application from development to staging
      (for testing) and then up to production. So rather than
      making the change in the asax file and recompiling every
      time before pushing the application up to the next stage I
      just open the web.config and make the change.

      I guess it's all just preference, whatever you feel most
      comfortable in doing, but I vote for web.config

      Jeremy
      [color=blue]
      >-----Original Message-----
      >Your web.config file is generally considered a better[/color]
      place because it's a[color=blue]
      >simple text file that is easily updated without needing[/color]
      to recompile[color=blue]
      >anything and changes go into effect immediately.
      >
      >--
      >I hope this helps,
      >Steve C. Orr, MCSD, MVP
      >http://Steve.Orr.net
      >Hire top-notch developers at http://www.able-[/color]
      consulting.com[color=blue]
      >
      >
      >
      >"D. Shane Fowlkes" <shanefowlkes @h-o-t-m-a-i-l.com> wrote[/color]
      in message[color=blue]
      >news:%23n0KceT 2DHA.1744@TK2MS FTNGP12.phx.gbl ...[color=green]
      >> Upon reading through my ASP.NET book, I've learned how[/color][/color]
      to place the[color=blue][color=green]
      >> connection string in both locations in my application.[/color][/color]
      Just due to habit,[color=blue]
      >I[color=green]
      >> naturally want to place my SQL Server connection string[/color][/color]
      in the asax[color=blue][color=green]
      >> file...but are there really advantages to having in one[/color][/color]
      file over the[color=blue]
      >other?[color=green]
      >>
      >> Thanks
      >>
      >>[/color]
      >
      >
      >.
      >[/color]

      Comment

      Working...