gpt4 book ai didi

c# - ELMAH - 在生产环境中未收到电子邮件

转载 作者:太空狗 更新时间:2023-10-29 22:56:36 24 4
gpt4 key购买 nike

我已经集成了 ELMAH 库来记录错误。我已经集成了用于获取错误列表但无法获取这些错误的电子邮件代码。谁能帮助我。下面是我在web.config中的配置代码

Web.config 文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>

<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
</system.web>

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
</modules>
</system.webServer>

<elmah>

<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/ElmahLog" />
<errorMail from="error@devtracker.com"
to="ankitkanojia.rs@gmail.com"
subject="Devtracker - Error occurs"
async="true" />

<security allowRemoteAccess="false" />
</elmah>


<location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
</location>

</configuration>

最佳答案

在查看您的问题后,我发现您只是忘记添加电子邮件设置。在您的 web.config 中添加以下行。确保更改主机名、端口、用户名和密码。

<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="host address" port="12345" userName="username here" password="password here"/>
</smtp>
</mailSettings>
</system.net>

关于c# - ELMAH - 在生产环境中未收到电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57971821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com