If the webpart need to access Sharepoint server info, there are 3 options when deploying the webpart in security context:
- Deploy to GAC, and no other settings need to be changed. Downside: need to recycle application pool when upgrade; webpart will be available to all sites in same server.
- Deploy to \Bin, and change trust level in web.config to at least WSS_Medium. Downside: this grant the whole ASP.NET application higher access rights. This is very convinient in development stage.
- Deploy to \Bin, and change trust level in web.config to wss_custom, then change/add the config file in \Program Files\Common Files\Microsoft Shared\web server extensions\12\config. This is safer because it only grant access to specified webparts. Recommended for production environment.
In any case, the webpart need to be signed (obviously) and marked as ‘SafeControl’ in web.config file.
If the webpart doesn’t need to access server resource, only need to mark it as SafeControl in web.config and add this line:
[assembly: AllowPartiallyTrustedCallers]
to the source file.
Posted by calvin998