简体   繁体   English

发布到 IIS 服务器后的 ASP.NET Identity with MySql 问题

[英]ASP.NET Identity with MySql problem after publishing to IIS server

I made a ASP.NET Web Api.我做了一个 ASP.NET Web Api。 I have my connection string inside web.config and it looks like this:我在 web.config 中有我的连接字符串,它看起来像这样:

<add name="AuthContext" connectionString="Data Source=*****; Initial Catalog=*****;Uid=*****;Pwd=****;SslMode=None;" providerName="MySql.Data.MySqlClient" />

This database is also on external server and can be reached from anywhere.该数据库也在外部服务器上,可以从任何地方访问。 On my local machine everythings works completely fine, but when i publish it to exteral IIS server i get that error:在我的本地机器上一切正常,但是当我将它发布到外部 IIS 服务器时,我收到该错误:

"The ADO.NET provider with invariant name 'MySql.Data.MySqlClient' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details.",

and also this:还有这个:

"InnerException": {
        "Message": "An error has occurred.",
        "ExceptionMessage": "Unable to find the requested .Net Framework Data Provider.  It may not be installed.",
        "ExceptionType": "System.ArgumentException",
        "StackTrace": "   at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)\r\n   at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type, Object key, Func`3 handleFailedLookup)"
    }

I would like to know why during connecting to dabase with for example ADO.NET i have to use我想知道为什么在使用例如 ADO.NET 连接到数据库时我必须使用

SslMode=None

In other case i get that error:在其他情况下,我收到该错误:

SSL 错误

it means handshake failed, unexpected package format Also i get another error in another controller and also only in IIS:这意味着握手失败,意外的包格式此外,我在另一个控制器中遇到另一个错误,并且仅在 IIS 中: 第二个错误

Alright, so in my web.config i added:好的,所以在我的 web.config 中我添加了:

<system.data>
   <DbProviderFactories>
     <remove invariant="MySql.Data.MySqlClient" />
     <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" 
          type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.13.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
   </DbProviderFactories>
</system.data>

and than everything worked fine然后一切正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM