Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
<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>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework" requirePermission="false" />
  </configSections>
  
  <connectionStrings>
    <add name="SCE" connectionString="metadata=res://*/SCE.csdl|res://*/SCE.ssdl|res://*/SCE.msl;provider=System.Data.SqlClient;provider connection string="data source=11.234.135.5;initial catalog=SCE2;persist security info=True;user id=ddd;password=sss;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
  </connectionStrings>
  
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="ClientValidationEnabled" value="true" />
   
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />

  </appSettings>
  
  <system.web>
    <customErrors mode="Off" defaultRedirect="/Error/Error">
      <error statusCode="403" redirect="/Error/NoPermissions" />
    </customErrors>
    <globalization uiCulture="en-GB" culture="en-GB" />
    <compilation targetFramework="4.5" debug="true" />
    <httpRuntime targetFramework="4.5" maxRequestLength="10240" requestLengthDiskThreshold="10024000" enableVersionHeader="false" />
    
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Index" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <sessionState timeout="2800" mode="StateServer">
    </sessionState>

    <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"/>
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
    </httpModules>

  </system.web>
  
  <system.webServer>

    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />

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

    </handlers>


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


   
  </system.webServer>
  
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>

  <elmah>
    <security allowRemoteAccess="0" />
    <errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="SCE"/>
    <errorMail from="admin@localhost.com" to="aazi@aa.com" subject="ELMAH Error Logged on SC" async="true"></errorMail>
  </elmah>

</configuration>


What I have tried:

The above is my web.configuration file.
Problem 1 : On bad url the email is sent to emailid but not saved in Sql database

problem 2 : i am not able to see elmah.axd file . Note : i have Authentication mode Forms.

Please help.
Posted
Updated 5-Mar-17 22:35pm
v6
Comments
CHill60 2-Mar-17 10:12am    
We can't answer your questions with just a configuration file!
Abrar Kazi 3-Mar-17 0:28am    
That is the only coding for Elmah setup i.e. WebConfig
CHill60 3-Mar-17 6:41am    
Elmah is for logging error details. Is your application trying to send emails and store data on a database OR are you trying to get Elmah to email details of the problem and also store details on a database. It is not clear from your post
Abrar Kazi 6-Mar-17 4:19am    
Yes i am trying to save the Errors in Sql Server as well i am trying to send an email
Suvendu Shekhar Giri 3-Mar-17 1:59am    
Have you tried debugging?
Anything you have to pinpoint the issue instead of this whole web.config file?

1 solution

Here's the obvious problem:
XML
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="SolutionCentreEntities"/>

Look at your <connectionStrings> section - the only connection string you've defined is an Entity Framework connection called SCE.

ELMAH doesn't use Entity Framework. You'll need to define a standard SQL connection string called SolutionCentreEntities, pointing to the ELMAH database you created.

If you haven't done so already, you'll need to download[^] and run the "MS SQL Server DDL Script".

The Ultimate ELMAH Tutorial: Logging to SQL Server[^]
Configuring ELMAH to use SQL Server ~ andyfrench.info[^]
 
Share this answer
 
Comments
Abrar Kazi 6-Mar-17 4:37am    
Yes i created another key for connectionstring and assigned it to Elmah to log in error using that connection string . Still it doesnt enter data to sql database. also i have given all the permissions to the database table and scripts .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900