ASP.NET 2.0, AllowPartiallyTrustedCallers ed il medium trust

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.

Detto ciò, la soluzione è la seguente. Installarsi Web Application Projects. Riporterà 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.

Nella stessa categoria

Commenti

Per inserire un commento, devi registrarti alla nostra community.

© 1998-2008 - ASP.NET, Media Center e tecnologia - Il blog di Daniele Bochicchio

TagCloud
.NET Framework, .NET Framework 2.0, .NET Framework 3.0, .NET Framework 3.5, 10annidi, ADO.NET, AJAX, Architettura, ASP, ASP.NET, ASP.NET 2.0, ASP.NET 2.0 per tutti, ASP.NET 3.5, ASP.NET AJAX, ASP.NET MVC, ASPItalia.com, Cache, CSS, Custom Control, Database, Databinding, Datagrid, Deployment, HttpHandler, HttpModule, HttpRuntime, IIS, ISAPI, Javascript, LINQ, LogParser, Master Pages, Media Center, Membership API, Microsoft Expression, Mono, MySQL, Object Oriented Programming, Off Topic, Office, Pattern, Profile API, Provider Model, Report, Roles API, Security, Silverlight, Silverlight 2.0, SQL Server, User Control, Visual Studio, Web Service, Windows CardSpace, Windows Client, Windows Live Services, Windows Mobile, Windows Presentation Foundation, Windows Server, Windows Vista, XAML, XBox 360, XHTML, XML, XSLT
BLOG INFO
  • Post: 827
  • Commenti: 344
  • TrackBacks: 178
  • Feed blog e contenuti tecnici: RSS
  • Feed blog: RSS Atom OPML

MVP
CATEGORIE
I PIÙ LETTI DEL MESE
IN EVIDENZA