using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Taste.DataAccess;
using Taste.DataAccess.Data.Repository.IRepository;
using Taste.DataAccess.Data.Repository;
using Microsoft.AspNetCore.Identity.UI.Services;
namespace Taste
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
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.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<IdentityUser, IdentityRole>()
.AddDefaultTokenProviders()
.AddEntityFrameworkStores<ApplicationDbContext>();
services.AddScoped<IUnitOfWork, UnitOfWork>();
services.AddMvc(options => options.EnableEndpointRouting = false)
.SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0);
services.AddControllersWithViews().AddRazorRuntimeCompilation();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseAuthorization();
app.UseMvc();
}
}
}
Could you show us your complete error message and complete code or describe your problem, so that we can better reproduce your problem.There is a "RegisterModel" in the error that you showed , but we didn't see it in your startup.cs. And from your Startup.cs,
I want to confirm with your version of net core in your project ,is 3.0?If it is 3.0 ,you should replace "app.UseMvc()" with "app.UseEndPoints()". From the code and error information you have given now, we could only suggest you to read the link below.
Could you tell me the "services.AddScoped<IUnitOfWork, UnitOfWork>()" in your code, Which package you referenced or how to customize it, when I add it, Compilation fails. Is your project using .net core3.0? In my 3.0 project, When I use "app.UseMvc()",Compilation
fails too.But i find someone has reported a similar error with you, you could read the details of this link :
None
0 Points
2 Posts
i have issue with register page
Oct 10, 2019 08:01 PM|anwafet|LINK
thi is the image
class Startup:
Member
180 Points
88 Posts
Re: i have issue with register page
Oct 11, 2019 03:24 AM|Lewis Lu|LINK
Hi anwafet,
Could you show us your complete error message and complete code or describe your problem, so that we can better reproduce your problem.There is a "RegisterModel" in the error that you showed , but we didn't see it in your startup.cs. And from your Startup.cs, I want to confirm with your version of net core in your project ,is 3.0?If it is 3.0 ,you should replace "app.UseMvc()" with "app.UseEndPoints()". From the code and error information you have given now, we could only suggest you to read the link below.
https://forums.asp.net/t/2154504.aspx?InvalidOperationException+Unable+to+resolve+service+for+type+Microsoft+AspNetCore+Identity+UserManager+1+Microsoft+AspNetCore+Identity+IdentityUser+while+attempting+to+activate+Mobile+Areas+Identity+Pages+Account+RegisterModel+
Best regards,
Lewis
None
0 Points
2 Posts
Re: i have issue with register page
Oct 11, 2019 10:54 AM|anwafet|LINK
Member
180 Points
88 Posts
Re: i have issue with register page
Oct 14, 2019 07:34 AM|Lewis Lu|LINK
Hi anwafet,
Could you tell me the "services.AddScoped<IUnitOfWork, UnitOfWork>()" in your code, Which package you referenced or how to customize it, when I add it, Compilation fails. Is your project using .net core3.0? In my 3.0 project, When I use "app.UseMvc()",Compilation fails too.But i find someone has reported a similar error with you, you could read the details of this link :
https://stackoverflow.com/questions/52089864/unable-to-resolve-service-for-type-iemailsender-while-attempting-to-activate-reg
Best regards,
Lewis