Configure Elmah email settings in code rather than config

微笑、不失礼 提交于 2019-12-13 03:33:46

问题


I'm setting up Elmah emails and I don't want to put my email account credentials in web.config.

I'm deploying on Azure and therefore would like to look up the credentials from Azure app settings in code on app startup.

Is there a way to configure Elmah emails declaratively in code rather than using the <errorMail> tag?


回答1:


The best way to do this is by overriding the SendMail method of Elmah's ErrorMailModule, as suggested by Atif Aziz in this discussion on Google Groups.

I've given more details in this answer.




回答2:


You could trap the Elmah Mailing event and substitute your email addresses.

http://scottonwriting.net/sowblog/archive/2011/01/06/customizing-elmah-s-error-emails.aspx



来源:https://stackoverflow.com/questions/21484728/configure-elmah-email-settings-in-code-rather-than-config

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!