Hello All,
We have Event Receiver on Library executed on Item Added. When we add document manually, Event Receiver triggered on Item Added and read values from web.config successfully.
string strUserName= System.Configuration.ConfigurationManager.AppSettings["UserName"];
We have another program, say “UploadContent”, it add document in Library programmatically. When program add document in Library, Event Receiver triggered on ItemAdded, but value from web.config show empty/null.
So we fetch web.config value by below code, but Event Receiver stops execution after below lines of code.
Configuration config = WebConfigurationManager.OpenWebConfiguration("/", properties.Web.Site.WebApplication.Name);
string strUserName = config.AppSettings.Settings["UserName"].Value;My questions is:
1. All Why Event Receiver not read web.config values, when document added programmatically in Library?
2. Why execution of Event Receiver stops after 2<sup>nd </sup>code snippet?
3. How to read values from web.config, when document added programmatically?
Any hell will be appreciable.
Thanks,
Amar Shinde