Я создал следующую папку и страницу в своем MVC Базовом приложении: Views-> Adminstration-> CreateRole.cs html
Я не тюк для просмотра страницы в своем браузере после перестройки.
This localhost page can’t be foundNo webpage was found for the web address: https://localhost:44310/Administration/createrole.cshtml
HTTP ERROR 404
Может ли это быть что-то в моей маршрутизации или в чем проблема?
startup.cs
public void Configure(IApplicationBuilder app,
IHostingEnvironment env, ApplicationDbContext context, RoleManager<ApplicationRole> roleManager, UserManager<ApplicationUser> userManager)
{
//
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/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.UseCookiePolicy();
app.UseAuthentication();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
SeedIdentity.Initialize(context, userManager, roleManager).Wait();
}
Контроллер Administration ниже:
public class AdministrationController : Controller
{
//private readonly RoleManager<IdentityRole> roleManager;
RoleManager<IdentityRole> roleManager;
UserManager<IdentityUser> userManager;
public AdministrationController(RoleManager<IdentityRole> roleManager, UserManager<IdentityUser> userManager)
{
//_roleManager = roleManager;
//_userManager = userManager;
}
/**
public AdministrationController(RoleManager<IdentityRole> roleManager)
{
this.roleManager = roleManager;
}**/
[HttpGet]
public IActionResult CreateRole()
{
return View();
}
[HttpPost]
public async Task<IActionResult> CreateRole(CreateRoleViewModel model)
{
if (ModelState.IsValid)
{
IdentityRole identityRole = new IdentityRole
{
Name = model.RoleName
};
IdentityResult result = await roleManager.CreateAsync(identityRole);
if (result.Succeeded)
{
return RedirectToAction("index", "home");
}
foreach (IdentityError error in result.Errors)
{
ModelState.AddModelError("", error.Description);
}
}
return View(model);
}
}
Я что-то упустил?