ASP.NET Website's BIN directory and references - asp.net

Imagine the following solution:
Website ABC.com (not Web Application)
BLL (business logic layer in a seperate assembly)
DTO (dto objects in their own assembly)
DAL (data access layer in it's own assembly as well).
The BLL has a reference to the DAL.
The BLL has a reference to the DTO layer.
The Website project references the BLL.
When one compiles the website project, the following DLLs will appear in the BIN directory:
BLL.dll
DTO.dll
DAL.dll
When one goes to preview the site, an error occurs about not having the necessary assembly references... Now if one right clicks on the website project, Add Reference, and explicitly add the reference to the missing assemblies, it will work fine.
It seems to me like ASP.NET pulls the referenced assemblies of the referenced assembly being added/referenced in the website.
Why does one need to add explicit references to the references of the references... ? Sorry if I'm not wording this correctly or if it confusing.

I think the problem may have to do with using a web site project, as oppossed to a Web Application. I can't remember off the top of my head, but there's something funky about the way web site projects are compiled, as oppossed to web application projects.

Here is a good article on your question Compilation and Deployment.
It has something to do with "WebSites" being compile at runtime. Hopefully the above article will answer your question.

Just tested this scenario today for the project I'm on. You should be just fine just adding your assembly in Web.config as:
<compilation debug="true">
<assemblies>
<clear/>
<add assembly="mscorlib"/>
<add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="YourBLLLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</assemblies>
</compilation>
Also your assemblies should stay in the famous ./bin folder of your web site's root.
GL!

Related

Why do we add dll in the web.config

What is the advantage of add assembly in the web.config
add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
aganist adding assembly to the reference
Any help is appreciated.
TIA
Here's a previous Stack Overflow question answering this (Web site vs Web App):
What is difference between web.config assemblies element and project file Reference element

ClaimsAuthenticationManager is not invoked

I'm facing a weird issue with the WIF ClaimsAuthenticationManager. I have registered the custom implementatin of the ClaimsAuthenticationManager in the web.config file:
<identityConfiguration>
<claimsAuthenticationManager type="<namespace>.CustomClaimsTransformer,<assembly>" />
<claimsAuthorizationManager type="<namespace>.CustomAuthorisationManager,<assembly>" />
....
When i run the application in the IISExpress the authenticate method of the ClaimsAuthenticationManager gets invoked. However, it's not being invoked ever since i deployed the application on IIS 7.5.
Is there any configuration that needs to be done?
In the system.webserver part of your web.config do you have the ClaimsAuthorizationModule set,
eg
<add name="ClaimsAuthorizationModule" type="Microsoft.IdentityModel.Web.ClaimsAuthorizationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
For .NET 4.5 you have to add this:
<add name="ClaimsAuthorizationModule" type="System.IdentityModel.Services.ClaimsAuthorizationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
ClaimsAuthenticationManager is not invoked automatically. One needs a plumbing code for that unless they are using WS-Federation.
You can do it in an PostAuthenticateRequest event handler for the HttpApplication.
A good example is located in the http://github.com/thinktecture/Thinktecture.IdentityModel.45 project. Search for ClaimsAuthenticationHttpModule.cs which invokes it.

RIA Services error but not used

I created an ASP.NET MVC WebPages application. Works perfectly local. Works perfectly on the server when I install it as a website. However when it is installed as an IIS application (level below another website, using the same application pool) all it does is throwing this exception:
Could not load file or assembly
'System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified.
Apparently something related to WCF RIA services, which is not used. All I use is Linq to SQL. How is this possible?
Server: Windows Server 2008 R2 with IIS 7.5
Check the web.config of your application if it contains an entry like:
<httpModules>
<add name="DomainServiceModule"
type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>
It is located in the <system.web> section.
Theres is also another entry like:
<modules runAllManagedModulesForAllRequests="true">
<add name="DomainServiceModule"
preCondition="managedHandler"
type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</modules>
in the <system.webserver> section.
Remove the entries, then you should not get the exception.
I know it too late, but may be my answer will be useful for some people.
I had similar problem, but no corresponded to IIS.
So, I had web app based on RIA services. This app used separate dll (DAL) which contained some classes attributed by RIA attributes (of course, it had reference to RIA dll). The dll (DAL) was referenced by another app which did not use RIA and raised same error as you mentioned (but only with System.ServiceModel.DomainServices.Server).
This error was raised only during WCF channel creation (ChannelFactory<>). So I suppose WCF should know about all referenced dlls during analyzing of attributes of contract's classes. But I did not found any explanation why WCF don't used only own attributes whithout analizing all of them.

asp.net mvc deployment

Ive managed to get asp.net mvc up and running on an iis6 server, but I keep getting silly messages like 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial'
I've got all the required dlls and even installed mvc from
http://www.microsoft.com/downloads/details.aspx?FamilyID=c9ba1fe1-3ba8-439a-9e21-def90a8615a9&displaylang=en
any clues about what Im missing?
Cheers
RenderPartial is an extension method and is defined in System.Web.Mvc.
So check out if you have in root Web.config lines adding System.Web.Extensions assembly:
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
in <configuration> <system.web> <compilation> <assemblies> node.
Thanks all for your suggestions and also more importantly for your contributions which has made this site the great site. I dont know what I would do without this site and you guys. Thanks
this link fixed it, replacing the compilers section of the web config did it 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'RenderPartial' - ASP.Net MVC
You are most probably missing this from your web.config:
<add namespace="System.Web.Mvc.Html"/>

How to use chart control's assemblies in application without installing it?

I am using a web application in which there is a chart control. I had installed the Microsoft chart control exe and Visual studio add on.
The problem is that when I upload the application on the server, there is a problem with the two assemblies missing System.Web.DataVisualization.Design.dll and System.Web.DataVisualization.dll.
So, I want to uninstall the Microsoft chart control exe & Visual studio add on, and instead only use the DLL in the application by giving reference in it.
Now, how do I define chart control on an ASPX page? How do I register the assemblies on the ASPX page and how can I get the chart control from it?
I think you can just add the DLL's to your Bin directory of your website.
Installing the chart controls locally simply adds the DLL's to your computer somewhere (I think). And I believe that the Add-In is to give you support for design mode. It doesn't install anything specific to your projects.
However, you may need to register the controls either on the page or in the web.config. For example, here is the registration of the AjaxControlToolkit controls in the web.config:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.web>
<pages>
<controls>
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
</controls>
</pages>
</system.web>
</configuration>
I have solved the problem.
First, add the library System.Web.DataVisualization.dll as reference.
Then, add the following line in web.config, inside <httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
You may see DataVisualization.Charting.ChartHttpHandler in red, it will build and run successfully. This may be a ReSharper bug.

Resources