“ http:// localhost / Identity / account”可以访问,但是在我的项目中没有。为什么在那儿,我该如何摆脱呢?

时间:2018-10-03 14:10:38

标签: c# asp.net-core .net-core asp.net-identity asp.net-core-2.0

前一段时间我确实运行了身份支架,但是不久之后我又将其连同所有文件一起删除了。我确实打算稍后再将其恢复,但我不希望在该URL上使用它。

我尝试删除bin / obj,甚至将其移至另一台计算机。我的项目中的任何地方都没有register.cshtml文件,但是,我仍然可以访问Url,登录,更改密码等。

是什么导致URL可访问?如何禁用它?

enter image description here Program.cs

public class Program
{
    public static void Main(string[] args)
    {
        var builder = WebHost.CreateDefaultBuilder(args);
        builder.UseStartup<Program>();

        var build = builder.Build();
        build.Run();
    }

    public void ConfigureServices(IServiceCollection services)
    {
        services.Configure<CookiePolicyOptions>(options =>
        {
            options.CheckConsentNeeded = context => true;
            options.MinimumSameSitePolicy = SameSiteMode.None;
        });

        services.AddScoped(typeof(AdminBuilder));

        var mvc = services.AddMvc();
        mvc.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
    }

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

        app.UseHttpsRedirection();
        app.UseStaticFiles();
        app.UseAuthentication();
        app.UseCookiePolicy();
        app.UseMvcWithDefaultRoute();
    }
}

IdentityHostingStartup.cs

[assembly: HostingStartup(typeof(MyProjectWebsite.IdentityHostingStartup))]
namespace MyProjectWebsite
{
    public class IdentityHostingStartup : IHostingStartup
    {
        public void Configure(IWebHostBuilder builder)
        {
            builder.ConfigureServices((context, services) => 
            {
                services.AddDbContext<MyProjectDbContext>();
                services.AddDefaultIdentity<SMyProjectUser>().AddEntityFrameworkStores<MyProjectDbContext>();
            });
        }
    }
}

0 个答案:

没有答案