ANCM进程内启动失败

时间:2020-04-24 23:28:39

标签: c# http core

我开发了一个使用.net core 3.1.3的项目,Localhost可以正常工作。服务器上的错误。我在互联网上做了很多研究。我尝试了所有所说的方法,但是问题并没有得到解决。 enter image description here

我的服务器功能

enter image description here

我如下更改了服务器上的应用程序池。

enter image description here enter image description here

我将托管所需的文件上传到服务器 enter image description here

在我的项目下面的nup文件中安装

enter image description here enter image description here enter image description here enter image description here

发布后我的Web配置文件如下

<?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=".\Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>

最后,我的启动文件如下

using DataAccess.EntityFreamwork;
using Entities.Domain;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.IO;
using Business.Helper;
using Business.ManagersApp;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.FileProviders;



namespace Web
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        readonly UserManagerApp _userManagerApp = new UserManagerApp();
        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {

            services.AddDbContextPool<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DatabaseConnection")));
            services.AddIdentity<ApplicationUser, IdentityRole>().AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();
            services.AddTransient<ApplicationDbContext>();
            services.AddSession();
            services.AddRazorPages();
            services.AddRouting();
            services.AddAuthentication(options =>
                {
                    options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                    options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                })
                //.AddFacebook(options =>
                //{
                //    options.AppId = Configuration["Authentication:Facebook:AppId"];
                //    options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
                //})
                //.AddGoogle(options =>
                //{
                //    options.ClientId = Configuration["Authentication:Google:ClientId"];
                //    options.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
                //}).AddTwitter(options =>
                //{
                //    options.ConsumerKey = Configuration["Authentication:Twitter:ConsumerAPIKey"];
                //    options.ConsumerSecret = Configuration["Authentication:Twitter:ConsumerSecret"];
                //}).AddMicrosoftAccount(microsoftOptions =>
                //{
                //    microsoftOptions.ClientId = Configuration["Authentication:Microsoft:ClientId"];
                //    microsoftOptions.ClientSecret = Configuration["Authentication:Microsoft:ClientSecret"];
                //})
                .AddCookie(config =>
                {
                    config.Cookie.Name = "login";
                    config.LoginPath = "/Account/Login";
                    config.ExpireTimeSpan = TimeSpan.FromDays(1);
                });
            services.Configure<CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;

            });
            services.AddControllersWithViews();
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }
            app.UseHttpsRedirection();

            app.UseStaticFiles();
            app.UseSession();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
               endpoints.MapControllerRoute(
                        name: "default",
                        pattern: "{controller=Home}/{action=Index}/{id?}");

                endpoints.MapControllerRoute(
                    name: "areas",
                    pattern: "{area}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
        }

    }
} 

我不知道还能做什么

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UserSecretsId>41e7fd2c-e5a3-4474-8f68-166bda4a7546</UserSecretsId>
  </PropertyGroup>

和我的Web.exe

我的Web.Exe错误

Unhandled exception. System.IO.DirectoryNotFoundException: C:\inetpub\Web\
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root,
 ExclusionFilters filters)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root)

   at Microsoft.Extensions.Configuration.FileConfigurationExtensions.SetBasePath
(IConfigurationBuilder builder, String basePath)
   at DataAccess.EntityFreamwork.ApplicationDbContext.OnConfiguring(DbContextOpt
ionsBuilder optionsBuilder) in C:\Users\borah\Source\Repos\Hospital\DataAccess\E
ntityFreamwork\DatabaseContext.cs:line 113
   at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
   at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
   at Microsoft.EntityFrameworkCore.DbContext.Set[TEntity]()
   at DataAccess.EntityFreamwork.Repository`1..ctor() in C:\Users\borah\Source\R
epos\Hospital\DataAccess\EntityFreamwork\Repository.cs:line 18
   at Business.Abstract.ManagerBase`1..ctor() in C:\Users\borah\Source\Repos\Hos
pital\Business\Abstract\ManagerBase.cs:line 13
   at Business.ManagersApp.UsersDetailManagerApp..ctor()
   at Business.ManagersApp.UserManagerApp..ctor() in C:\Users\borah\Source\Repos
\Hospital\Business\ManagersApp\UserManagerApp.cs:line 53
   at Web.Startup..ctor(IConfiguration configuration) in C:\Users\borah\Source\R
epos\Hospital\Web\Startup.cs:line 29
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMat
cher.CreateInstance(IServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance
(IServiceProvider provider, Type instanceType, Object[] parameters)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startup
Type, HostBuilderContext context, IServiceCollection services)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.<
UseStartup>b__0(HostBuilderContext context, IServiceCollection services)
   at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at Web.Program.Main(String[] args) in C:\Users\borah\Source\Repos\Hospital\We
b\Program.cs:line 10

1 个答案:

答案 0 :(得分:0)

我解决了以下问题。但这一次还有另一个问题.Ajax Post不起作用。用户名和密码如果错误则起作用,但是如果返回的数据正确,则不起作用。现在我正在处理:)

enter image description here