使用 sharepoint 2007 的 Gac 或 bin 中的 Web 部件 dll
sharepoint 2007 Web 部件部署中的最佳实践是什么。 将 dll 部署到 GAC 或 bin?
What is best practice, in sharepoint 2007 web part deployment. Deploying the dll's to GAC or bin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与通常的最佳实践一样,这取决于您的情况。 将 dll 放入 GAC 意味着它们必须是强命名的,并且将获得完全信任。 这使得部署变得简单而美好,但根本不会对代码进行代码访问安全(CAS)检查,它将是完全可信的。 GAC 中的程序集还可以在服务器上的其他站点上重复使用,而无需部署多个副本。
部署到 bin 意味着您需要了解 webpart 的 CAS 要求,并且如果您需要执行 web.config 中设置的信任级别不允许的操作,则需要将信任级别提升为完全信任(而不是推荐),或使用适当的配置创建自定义信任级别。 有关此内容的更多详细信息,请参见此处:
http://msdn.microsoft.com/en-us/library/cc768613。 在
回到问题,对于 Intranet 站点,没有外部访问该站点,并且 Web 部件正在使用的数据不敏感(例如工资),我将部署到 GAC, 为了让事情变得简单。
对于可从 Web 访问的应用程序或处理敏感数据的内部应用程序,出于安全原因,我通常会选择 bin 部署。
As usual with best practices, it depends on your situation. Putting the dll's into the GAC means that they must be strong named, and will get full trust. This makes it nice and simple to deploy, but there will be no Code Access Security (CAS) checks on the code at all, it will be fully trusted. Assemblies in the GAC can also be re-used on other sites on the server without the need to deploy multiple copies.
Deploying to bin means that you need to understand the CAS requirements for your webpart, and if you need to do something that is not allowed in the trust level set in web.config, you need to either elevate the trust level to full trust (not recommended), or create a custom trust level with the appropriate configuration. More details on this can be found here:
http://msdn.microsoft.com/en-us/library/cc768613.aspx
Back to the question, for intranet sites, where there are no external access to the site, and the data the web part is working with is not sensitive (salaries for example), I would deploy to the GAC, in order to keep things simple.
For an application that will be accessible from the web, or an internal applicaiton handling sensitive data, I would generally go with bin deployment for security reasons.