Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ELMAH-在生产环境中未收到电子邮件_C#_Asp.net Mvc_Elmah - Fatal编程技术网

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

C# ELMAH-在生产环境中未收到电子邮件,c#,asp.net-mvc,elmah,C#,Asp.net Mvc,Elmah,我集成了ELMAH库来记录错误。我集成了获取错误列表的电子邮件代码,但无法获取这些错误。有人能帮我吗。下面是我在web.config中的配置代码 Web.config文件 <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <sectionGroup name="elmah"> <section name="security"

我集成了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>


所有功能都集成在一起,工作完美,似乎只有自动电子邮件发送功能不起作用。@Suchit的回答是正确的。但是对于将来类似的问题,您可以使用。@ThomasArdal非常感谢您的投入,我们将继续关注。