简体   繁体   English

启动应用程序时发生错误,一旦我在 IIS 上运行我的 ASP.NET 核心项目

[英]An error occurred while starting the application, once I run my ASP.NET Core project on IIS

I want to publish an ASP.NET Core 3.1 application to IIS.我想将 ASP.NET Core 3.1 应用程序发布到 IIS。

I faced to some problems.我遇到了一些问题。 I added dotnet-hosting-3.1.3-win and changed the applicationPool to "No managed code".我添加了dotnet-hosting-3.1.3-win并将 applicationPool 更改为“无托管代码”。

My web.config in the publish folder looks like this我在发布文件夹中的web.config看起来像这样

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <location path="." inheritInChildApplications="false">
        <system.webServer>
            <handlers>
                <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
            </handlers>
            <aspNetCore processPath="dotnet" 
                        arguments=".\Mehmanpazir.dll" 
                        stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" 
                        hostingModel="OutOfProcess" />
        </system.webServer>
    </location>
</configuration>
<!--ProjectGuid: 9df390e8-96df-4f6c-bc6b-f5fc9306940e-->

Ultimately I couldn't solve this problem.最终我无法解决这个问题。

An error occurred while starting the application.启动应用程序时发生错误。

and my log is:我的日志是:

crit: Microsoft.AspNetCore.Hosting.Diagnostics[6] Application startup exception System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'IIS APPPOOL\campaign'.致命一击:Microsoft.AspNetCore.Hosting.Diagnostics[6] 应用程序启动异常 System.Data.SqlClient.SqlException (0x80131904):用户 'IIS APPPOOL\campaign' 登录失败。 at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool. at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken) at System.Data. SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 选项,DbConnectionPoolKey poolKey,Object poolGroupProviderInfo,DbConnectionPool 池,DbConnection owningConnection,DbConnectionOptions userOptions)在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool 池,DbConnection owningObject,DbConnectionOptions,DbConnectionPool 选项,DbConnectionPool 选项,DbConnectionPool 选项)在 System.Data.ProviderBase.DbConnectionPool。 CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.P CreateObject(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection)在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject,DbConnectionOptions userOptions,DbConnectionInternal oldConnection)在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject,UInt32 waitForMultipleObjectsTimeout,Z27226C864BAC7454A855EDB , Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource 1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource重试,DbConnectionOptions userOptions,DbConnectionInternal oldConnection,DbConnectionInternal& 连接)在 System.Data.P roviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource 1 retry) at System.Data.SqlClient.SqlConnection.Open() at ElmahCore.Sql.SqlErrorLog.CreateTableIfNotExists() at ElmahCore.Sql.SqlErrorLog..ctor(String connectionString) at ElmahCore.Sql.SqlErrorLog..ctor(IOptions 1 option) --- End of stack trace from previous location where exception was thrown --- at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeReso roviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource 1 retry, DbConnectionOptions userOptions) 在 System.Data.SqlClient。 SqlConnection.TryOpen(TaskCompletionSource 1 retry) at System.Data.SqlClient.SqlConnection.Open() at ElmahCore.Sql.SqlErrorLog.CreateTableIfNotExists() at ElmahCore.Sql.SqlErrorLog..ctor(String connectionString) at ElmahCore.Sql.SqlErrorLog..ctor(IOptions 1 选项) --- 从先前引发异常的位置结束堆栈跟踪 --- 在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeReso lverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor 2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor 2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.b__0(ServiceProviderEngineScope scope) at Microsof lverContext context) 在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor 2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor 2.VisitCallSite(ServiceCallSite callSite, TArgument argument) 在 Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve( ServiceCallSite callSite, ServiceProviderEngineScope 范围)在 Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.b__0(ServiceProviderEngineScope 范围)在 Microsoft t.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope) t.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(类型 serviceType,ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) at Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_0.b__0(RequestDelegate next) at Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()在 Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) 在 Microsoft.Extensions.Internal.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) 在 Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object [] 参数)在 Microsoft.AspNetCore.Builder.ApplicationBuilder.Build() 的 Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass4_0.b__0(RequestDelegate next)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) ClientConnectionId:c07813a4-0039-47e3-b476-6fdccf2d18f1 Error Number:18456,State:1,Class:14 info: Microsoft.Hosting.Lifetime[0] Now listening on: http://127.0.0.1:2942 info: Microsoft.Hosting.Lifetime[0] Application started. at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken) ClientConnectionId:c07813a4-0039-47e3-b476-6fdccf2d18f1 Error Number:18456,State:1,Class:14 info: Microsoft.Hosting.Lifetime[0] Now listening on : http://127.0.0.1:2942信息:Microsoft.Hosting.Lifetime[0] 应用程序已启动。 Press Ctrl+C to shut down.按 Ctrl+C 关闭。 info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: E:\development\Mehmanpazir\teachwebapi\bin\Release\publish信息:Microsoft.Hosting.Lifetime[0] 托管环境:生产信息:Microsoft.Hosting.Lifetime[0] 内容根路径:E:\development\Mehmanpazir\teachwebapi\bin\Release\publish

I found a solution for my problem.我找到了解决我的问题的方法。 I used windows authentication in connection string which issuer couldn't connect to my database.After changing connection to connect with username and password,it became alright.我在连接字符串中使用了 windows 身份验证,发行人无法连接到我的数据库。更改连接以使用用户名和密码连接后,一切正常。

暂无
暂无

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

相关问题 Azure WebApp Asp.NET Core 2 错误:启动应用程序时出错 - Azure WebApp Asp.NET Core 2 error: An error occurred while starting the application ASP.NET 5 启动应用程序时出错 - ASP.NET 5 An error occurred while starting the application 在 SmarterAsp.net WebApplication Asp.NET Core 2.2 中托管时“错误:启动应用程序时发生错误” - " Error: An error occurred while starting the application " while hosting in SmarterAsp.net WebApplication Asp.NET Core 2.2 ASP.NET Core 1.1 在本地运行良好,但在发布到 Azure 时显示“启动应用程序时出错”。 - ASP.NET Core 1.1 runs fine locally but when publishing to Azure says “An error occurred while starting the application.” 我在 iis express 中运行 asp.net core mvc 项目时遇到问题 - I have problem while running asp.net core mvc project in iis express 启动ASP.NET Core应用程序后如何启动Web浏览器? - How do I launch the web browser after starting my ASP.NET Core application? 为什么我的ASP.NET 5应用程序不能在IIS 7.5上运行? - Why does my ASP.NET 5 Application Not Run On IIS 7.5? 如何在本地IIS 7中运行asp.net项目 - How can I run asp.net project Locally IIS 7 在类“程序”上调用方法“ BuildWebHost”时发生错误。 没有应用程序服务提供者就可以继续-ASP.NET CORE迁移 - An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider - ASP.NET CORE Migration ASP.NET Core 3.1 Web 应用程序在 IIS Express 上运行时抛出错误 500.30,但在使用 dotnet watch run 时不会抛出错误 - ASP.NET Core 3.1 web application throws error 500.30 when run on IIS Express, but not when using dotnet watch run
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM