gpt4 book ai didi

asp.net-mvc - ELMAH 缺少连接字符串

转载 作者:行者123 更新时间:2023-12-03 05:29:24 25 4
gpt4 key购买 nike

我正在尝试配置 ELmah与我的 mvc 应用程序一起使用。

错误提示

Connection string is missing for the SQL error log

但是我检查了我的 Web.config,连接字符串就在那里。我不确定是什么导致了这个问题。在ErrorLogPage.cs中,connectionString始终具有空值

 public SqlErrorLog(IDictionary config)
{
if (config == null)
throw new ArgumentNullException("config");

string connectionString = ConnectionStringHelper.GetConnectionString(config);

//
// If there is no connection string to use then throw an
// exception to abort construction.
//

if (connectionString.Length == 0)
throw new ApplicationException("Connection string is missing for the SQL error log.");

_connectionString = connectionString;

...
}

网络配置

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

<connectionStrings>
<add name="sql-elmah" providerName="System.Data.SqlClient" connectionString="Data Source=xxx;Initial Catalog=xxx;user=xxx;password=xxx" />
<add name="EFDbContext" providerName="System.Data.SqlClient" connectionString="Data Source=yyy;Initial Catalog=yyy;user=yyy;password=yyy;" />
</connectionStrings>

<elmah>
<security allowRemoteAccess="0" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="sql-elmah" />
</elmah>

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

<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</httpModules>
</system.web>

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />

<modules>
<add name="Elmah.ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
</modules>

<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" preCondition="integratedMode" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>
</system.webServer>

</configuration>

最佳答案

我删除了 Elmah 引用。单击“管理 Nuget 包”按钮再次添加 Elmah 引用。在线浏览“Elmah”并安装。之后,错误更改为“无法加载System.Data.SQLite”。我使用相同的过程来安装 SQLite。问题已解决

关于asp.net-mvc - ELMAH 缺少连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18221036/

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