美文网首页
.net core 发布后的站点启动报错

.net core 发布后的站点启动报错

作者: wwmin_ | 来源:发表于2019-05-29 22:36 被阅读0次

    错误如下:

    .An error occurred while starting the application.
    .NET Core 4.6.27414.06 X86 v4.0.0.0 | Microsoft.AspNetCore.Hosting version 2.1.1-rtm-30846 | Microsoft Windows 6.1.7601 S | Need help?

    一般情况下在本地跑没问题,发布到服务器后出现问题就要查看错误信息, 如果请求中没写明,那就得打开iis日志查看了.
    修改发布后的web.config 修改如下

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <location path="." inheritInChildApplications="false">
        <system.webServer>
          <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
          </handlers>
          <aspNetCore processPath=".\someApi.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
        </system.webServer>
      </location>
    </configuration>
    <!--ProjectGuid: 35a709bd-73f3-4f4e-b6c8-812a3da60d8d-->
    

    其实就是将stdoutLogEnabled的值由原来的false改为true,
    修改完之后还要重启iis或刷新iis,然而刷新一下浏览器或请求之后并没有看到log, 原因是系统没有自动创建logs文件夹,需要我们手动创建,在网站跟目录创建logs文件夹后同样要重启iis或刷新iis才能生效,请求一下接口就可以看到logs文件夹下的stdout_**_*****.log文件了,然后就可以查看错误信息了,

    Application startup exception: System.ArgumentException: The directory name 'D:\web\someApi\upload\' does not exist.
    Parameter name: path
       at System.IO.FileSystemWatcher..ctor(String path, String filter)
       at System.IO.FileSystemWatcher..ctor(String path)
       at Microsoft.Extensions.FileProviders.PhysicalFileProvider.CreateFileWatcher(String root, ExclusionFilters filters)
       at roadMarkerApi.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in D:\work\web\roadMarker\roadMarkerApi\roadMarkerApi\Startup.cs:line 154
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
       at Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
       at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
       at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
       at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
    crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
          Application startup exception
    System.ArgumentException: The directory name 'D:\web\someApi\upload\' does not exist.
    Parameter name: path
       at System.IO.FileSystemWatcher..ctor(String path, String filter)
       at System.IO.FileSystemWatcher..ctor(String path)
       at Microsoft.Extensions.FileProviders.PhysicalFileProvider.CreateFileWatcher(String root, ExclusionFilters filters)
       at roadMarkerApi.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in D:\work\web\roadMarker\roadMarkerApi\roadMarkerApi\Startup.cs:line 154
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
       at Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter.<>c__DisplayClass4_0.<Configure>b__0(IApplicationBuilder app)
       at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
       at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
       at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
    Hosting environment: Production
    Content root path: D:\web\someApi
    Now listening on: http://127.0.0.1:37812
    Application started. Press Ctrl+C to shut down.
    
    

    我的这里出现的问题是上传文件时新建了upload文件夹,但是生成的时候并没有带过来,所以新建一个就可以了

    相关文章

      网友评论

          本文标题:.net core 发布后的站点启动报错

          本文链接:https://www.haomeiwen.com/subject/bizutctx.html