【问题标题】:Asp.net Core Error when publish on IIS 10在 IIS 10 上发布时出现 Asp.net Core 错误
【发布时间】:2018-01-03 20:17:44
【问题描述】:

我发布了我的应用程序并收到此错误:

启动应用程序时出错。

.NET Core X64 v4.1.1.0 | Microsoft.AspNetCore.Hosting 版本 1.1.1 |微软视窗 10.0.14393 |需要帮助吗?

查看日志文件:

Application startup exception: System.FormatException: Could not parse the JSON file. Error on line number '9': '"ConnectionStrings": {
"EstudantesCV21Context": "Provider=SQLOLEDB.1;Password=******;Persist Security Info=True;User ID=sa;Initial Catalog=EstudantesCV21Context-241ea716-db64-402d-955f-be4b264ce053;Data Source=*********"'. ---> Newtonsoft.Json.JsonReaderException: Bad JSON escape sequence: \S. Path 'ConnectionStrings.EstudantesCV21Context', line 9, position 209.
   at Newtonsoft.Json.JsonTextReader.ReadStringIntoBuffer(Char quote)
   at Newtonsoft.Json.JsonTextReader.ParseString(Char quote, ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ParseValue()
   at Newtonsoft.Json.Linq.JContainer.ReadContentFrom(JsonReader r, JsonLoadSettings settings)
   at Newtonsoft.Json.Linq.JContainer.ReadTokenFrom(JsonReader reader, JsonLoadSettings options)
   at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser.Parse(Stream input)
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)
   --- End of inner exception stack trace ---
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
   at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at EstudantesCV21.Startup..ctor(IHostingEnvironment env) in C:\Users\erito\onedrive\documentos\visual studio 2017\Projects\CadastroCV21\EstudantesCV21\Startup.cs:line 26
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
   at Microsoft.AspNetCore.Hosting.Internal.StartupLoader.LoadMethods(IServiceProvider hostingServiceProvider, Type startupType, String environmentName)
   at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.<>c__DisplayClass1_0.<UseStartup>b__1(IServiceProvider sp)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureStartup()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Hosting environment: Production
Content root path: C:\WebSite
Now listening on: http://localhost:18998
Application started. Press Ctrl+C to shut down.

连接字符串:

{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "ConnectionStrings": {
    "EstudantesCV21Context": "Server=myserver\SQLEXPRESS;Database=mydatabase;userid=myid;password=mypass"
  }
}

【问题讨论】:

  • 我不知道,但我认为不是,我在 Windows Server 16 上发布,更改连接字符串后出现此错误。
  • 这不是解决方案,但请按照该答案查看实际错误是什么。 “启动应用程序时发生错误”非常通用,可以让任何人真正了解解决您的问题。
  • 我提出了登录问题,我需要修复字符串连接。
  • 您连接到什么数据库... SQLOLEDB 真的很旧,并且没有与 SQL Server 或 SQLite 一起用于 EFC... 您能否向我们展示您的连接字符串原因,这会有所启发关于这个问题。

标签: asp.net asp.net-core-mvc iis-10


【解决方案1】:

我不知道你是否还需要这个问题的答案。我遇到了这个问题,我通过像这样更改连接字符串来解决它。添加双反斜杠

{ "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Warning" } }, "ConnectionStrings": { "EstudantesCV21Context": "Server=myserver\\SQLEXPRESS;Database=mydatabase;userid=myid;password=mypass" } }

【讨论】:

    猜你喜欢
    • 2016-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-03
    • 1970-01-01
    相关资源
    最近更新 更多