加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – Elmah没有发送电子邮件

发布时间:2020-12-16 03:28:35 所属栏目:asp.Net 来源:网络整理
导读:我在我的Mvc4应用程序中实现了Elmah.我的web.config如下: – configuration configSections sectionGroup name="elmah" section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler,Elmah" / section name="errorLog" requireP
我在我的Mvc4应用程序中实现了Elmah.我的web.config如下: –

<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>

    <elmah>
        <security allowRemoteAccess="1" />
        <errorLog type="Elmah.XmlFileErrorLog,Elmah" logPath="~/App_Data"/>
        <errorMail from="test@test.in" to="test1@test.in" subject="Elmah Report" async="true" smtpServer="mail.test.in" />            
    </elmah>

  <connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.SQLEXPRESS;Initial Catalog=aspnet-Mvcjquery-20130225111502;Integrated Security=SSPI" />
  </connectionStrings>   

    <system.web>
      <httpHandlers>
          <add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory,Elmah" />         
      </httpHandlers>

      <httpModules>
          <add name="ErrorLog" type="Elmah.ErrorLogModule,Elmah"/>
          <add name="ErrorMail" type="Elmah.ErrorMailModule,Elmah"/>

     </httpModules>        
  </system.web>

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

      <handlers>
          <add name="Elmah" path="elmah.axd" verb="POST,HEAD" type="Elmah.ErrorLogPageFactory,Elmah" preCondition="integratedMode" />         
      </handlers>
  </system.webServer>    

</configuration>

我添加了代码以通过elmah发送电子邮件.我可以通过输入url localhost://elmah.axd看到错误.但是我没有收到mail.Pls帮助

解决方法

尝试使用async =“false”:

<errorMail 
    from="join@assert.in" 
    to="twinkle@assert.in" 
    subject="Elmah Report" 
    async="false" 
    smtpServer="mail.assert.in" />

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读