Pros and cons of registering user controls in the web.config vs asp file

Can someone please let me know the pros and cons of registering user controls in web.config and on top of asp pages?

I am looking for performance issues in particular. Does all the controls registered in web.config have slower loading pages (even pages that don't use these controls)?

+4
source share
3 answers

Web.config pros

  • Only 1 place to add an extra bit of code

Web.config cons

  • Sometimes I forget to update web.config in the production environment, since I never copy web.config from the staging area to a live site.

On each page pros

  • When deploying / publishing pages and / or copying pages from dev / test / staging to a live server, you do not need to worry about updating web.config

One page minus

  • On each page, therefore, if something changes, it is a pain to go through each page and fix it.
  • You need to add it manually to each page.

I would recommend doing this in web.config. This works less for you since you need to remember to add it to every page. Although, if you have a ton and lots are used on only one page, you can do a little to keep your web.config a little less cluttered. I usually put my controls in web.config if I use them on multiple pages. If it is used on only one page, I usually just declare it on my asp.net page.

+5
source

An old question, but finally the answer to performance! There is no difference:

http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-user-controls-and-custom-controls-in-web-config.aspx#1056687

The good news is there is no performance difference between registering them in the web.config file or at the top of the page.

The execution performance is exactly the same (they are compiled to the same instructions in both scenarios).

Compilation should also compile with the same performance.

+1
source

Not a hell of a lot to put it in web.config. This is simply not possible with drag and drop, so many simply do not. Keeps the page less cluttered and simplifies long-term change.

0
source

All Articles