开发者

SharePoint SPItemEventReceiver environment configuration

开发者 https://www.devze.com 2022-12-18 14:19 出处:网络
I have a class that inherits from SPItemEventReceiver and implements ItemAdded, ItemUpdated, and ItemDelete开发者_JAVA技巧d.These all work just fine and I\'m getting the data I need.

I have a class that inherits from SPItemEventReceiver and implements ItemAdded, ItemUpdated, and ItemDelete开发者_JAVA技巧d. These all work just fine and I'm getting the data I need.

However, I want to push some of the data to a 3rd party server via a web service. What is the best way to configure the external dependency of the web service for various environments (dev/test/production) without hard-coding the end point for each environment?

I'd prefer to avoid any static *.ini type files if possible. Can I add a configuration section to SharePoint's web.config and read it from the event handler?


Yes, best place to store that settings is web.config file. Below, some related articles:

  • Event handlers configuration settings best practices
  • Reading Settings from the Web.Config file from an Event Handler


Think of it like that - what would happen if you created yet another site of the same type and having the same event receiver and everything. Would you still use the same configuration? Is it a setting per each list? Per website? Per server farm? If you decide it's a server farm setting, then web.config is good for you. If you think that each web needs different config, then you have to persist the configuration somewhere else. For instance, if it's at web level, you can write your config string to SPWeb.Properties. This setting can later be read easily from that object, for instance SPContext.Current.Web.Properties["RemoteWebServiceURL"]. You can also set the value form a tiny PowerShell script. A SPList object has a similar property bag.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号