如何在 Sharepoint 2010 项目解决方案中包含自定义 web.config 文件
我创建了一个可视 Web 部件项目,希望在其中包含自定义 web.config 文件来维护 Web 部件的设置。我遵循的步骤是:单击“添加 xml 文件”,将其重命名为 web.config,然后将 appsettings 包含在该文件中并尝试在我的代码中使用它。
它不允许我这样做。您能否列出在项目中包含自定义 web.config 文件的步骤。
I created a Visual Web Part Project in which I want to include a custom web.config file to maintain the settings of my webpart. Steps I followed were: Clicked on Add xml file, renamed it to web.config and Then included the appsettings in this file and tried to use it my code.
It did not allow me to do so. Can you please list out the steps to include a custom web.config file in a project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您确定要将此设置放在 web.config 上吗?
web.config 在 Web 应用程序上的所有网站、网站集...之间共享。
您确定范围正确吗?
维护和更新也很困难。
您还有其他解决方案:
以下是一些有用的链接:
http://msdn.microsoft.com/en-us/library/ff798488.aspx
http://msdn.microsoft.com/en-us/library/ff647766.aspx
< a href="http://spconfigstore.codeplex.com/" rel="nofollow">http://spconfigstore.codeplex.com/
Are you sure you want to put this settings on the web.config ?
The web.config is shared across all sites, site collections... on a webapplication.
Are you sure it is the right scope ?
It is also difficult to maintain and to update.
You have other solutions :
Here are some useful links :
http://msdn.microsoft.com/en-us/library/ff798488.aspx
http://msdn.microsoft.com/en-us/library/ff647766.aspx
http://spconfigstore.codeplex.com/
您将无法包含 SharePoint Web 部件的自定义 web.config 文件。
您需要做的是创建一个
SPFeatureReceiver
,将其附加到 Web 部件部署包(即 WSP 文件)内的功能定义,并让接收器在功能激活时添加适当的 web.config 条目。为此,您应该使用SPWebConfigModification
类,用于在功能激活时添加条目并在功能停用时删除它们。You're not going to be able to include a custom web.config file for a SharePoint web part.
What you need to do is create an
SPFeatureReceiver
, attach it to the feature definition inside your web part deployment package (i.e. WSP file), and have the receiver add the appropriate web.config entries on feature activation. To do this, you should use theSPWebConfigModification
class to add the entries on feature activation and remove them on feature deactivation.请浏览下面提供的文章链接
http:// claytonj.wordpress.com/2008/03/19/custom-webconfig-settings-in-sharepoint/
希望这有帮助
kindly go through the article link provided below
http://claytonj.wordpress.com/2008/03/19/custom-webconfig-settings-in-sharepoint/
hope this helps