Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between web.config assemblies element and project file Reference element

I'm looking at an asp.net application, i notice that there are assemblies defined into two places. In web.config there is configuration/system.web/compilation/assemblies/add elements. In the project file there are references setup under the Project/ItemGroup/Reference elements.

I was wondering, what is the difference between assemblies/references added in either location?

like image 424
Neophyte.net Avatar asked Sep 29 '10 01:09

Neophyte.net


People also ask

What is web config file give the structure of the same?

A configuration file (web. config) is used to manage various settings that define a website. The settings are stored in XML files that are separate from your application code. In this way you can configure settings independently from your code.


1 Answers

In the web.config section:

The assemblies element defines a collection of assembly names that are used during compilation of an ASP.NET application.

Web site projects usually use the assemblies element as there is no project file storing location of references that the web site uses. The project references would not apply to a web site, as it has no proper project file to store these in, so must store all referenced assemblies in the web.config. There is some interesting, although not directly related, discussion here.

Web application projects may make use of both the assemblies element and project references.

Having a reference in the assemblies element also means you won't have to add the @register at the top of any .aspx pages that use that namespace. More discussion on that here.

like image 130
BlackICE Avatar answered Oct 13 '22 08:10

BlackICE