ASP.NET 2.0, AllowPartiallyTrustedCallers ed il medium trust

Daniele Bochicchio

di , in ASP.NET,

Sembra che ci sia problemi, giustamente, se si utilizza il CodeFile con ASP.NET 2.0 in un ambiente dove il trust è stato abbassato su medium.

Potremmo disquisire per ore sul perchè questo, alla fine, non serve praticamente a nulla per la sicurezza (basta scrivere un q.sa di unmanaged per usare i privilegi del processo e non quelli derivanti da CAS...), ma fatto sta che in questi giorni un po' di persone mi hanno portato l'orecchio questo problema.

[SecurityException: That assembly does not allow partially trusted callers.]

Detto ciò, la soluzione è la seguente. Installarsi Web Application Projects se si utilizza VS 2005, oppure con VS 2008 SP1 il supporto ai progetti web è già incluso (anche in versione Express). Si potrà usare il modello del CodeBehind, con conseguente compilazione dell'assembly in un solo file. Poi utilizzare l'attributo AllowPartiallyTrustedCallers:

<Assembly: AllowPartiallyTrustedCallers()>

Fatto questo, è sufficiente compilare tutto in un solo assembly e fare il deployment di quest'ultimo.

In alternativa, c'è anche la voce "Publish" sotto il menu "Build" che potrebbe fare al caso vostro, magari con Web Deploymnet Projects per compilare tutto (anche file sotto /App_Code/) in un solo assembly, anzichè farlo fare ad ASP.NET.

Commenti
ASP.NET 2.0, AllowPartiallyTrustedCallers ed il medium trust

Per inserire un commento, devi avere un account.

Fai il login e torna a questa pagina, oppure registrati alla nostra community.

Nella stessa categoria
I più letti del mese
TAG CLOUD
.NET Framework, .NET Framework 2.0, .NET Framework 3.0, .NET Framework 3.5, .NET Framework 4.0, .NET Micro Framework, 10annidi, ADO.NET, AJAX, Architettura, ASP, ASP.NET, ASP.NET 2.0, ASP.NET 2.0 per tutti, ASP.NET 3.5, ASP.NET 3.5 per tutti, ASP.NET 4.0, ASP.NET 4.0 Guida completa, ASP.NET AJAX, ASP.NET Charting, ASP.NET MVC, ASPItalia.com, C# 4 Guida completa, Cache, Community Days 2010, Community Days 2012, CSS, Custom Control, Database, Databinding, Datagrid, Deployment, Dynamic Data Control, Entity Framework, Expression Blend, HTML 5 Espresso, HTML5, HttpHandler, HttpModule, HttpRuntime, IIS, ISAPI, Javascript, jQuery, LINQ, LINQ to Entities, LINQ to SQL, LogParser, Master Pages, Media Center, Membership API, Metro, Microsoft Expression, MIX11, Model Virtual Casting, Mono, MySQL, Object Oriented Programming, Off Topic, Office, ORM, Parallel FX, Pattern, PDC 2008, Profile API, Provider Model, Real Code Day 6, Report, Roles API, Security, SEO, Silverlight, Silverlight 2.0, Silverlight 3.0, Silverlight 3.0 Guida Completa, Silverlight 4.0, SQL Server, User Control, Visual Basic 2010 Guida completa, Visual Studio, WCF Data Services, WCF RIA Services, Web Service, web.config, Windows 7, Windows 8, Windows Azure, Windows Client, Windows Communication Foundation, Windows Identity Foundation, Windows Live Services, Windows Phone, Windows Phone - il libro, Windows Phone 7, Windows Phone 7.1, Windows Presentation Foundation, Windows Server, Windows Vista, WinRT, XAML, XBox 360, XHTML, XML, XNA, XSLT
BLOG INFO
  • 1.019 post, 438 commenti, 195 trackback
  • Feed blog: RSS Atom
In evidenza