Найдите ошибку, упомянутую ниже,
Эта страница localhost не найдена
Не найдена веб-страница по веб-адресу: https://localhost:44370/
Пожалуйста, найдите Player.cs ниже
Код: Выделить всё
namespace Playersmanagementsystem.Models
{
public class Player
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Emailaddress { get; set; }
public int PhoneNumber { get; set; }
}
}
Код: Выделить всё
using Microsoft.EntityFrameworkCore;
using Playersmanagementsystem.Context;
using Playersmanagementsystem.Models;
namespace Playersmanagementsystem.Views
{
public class PlayersController : Controller
{
private readonly ApplicationDbContext _context;
public PlayersController(ApplicationDbContext context)
{
_context = context;
}
// GET: Players
public async Task Index()
{
return View(await _context.Players.ToListAsync());
}
}
}
В файле Program.cs ниже
п>
Код: Выделить всё
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Playersmanagementsystem.Context;
namespace Playersmanagementsystem
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
builder.Services.AddDbContext(options =>
options.UseSqlServer(connectionString));
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
builder.Services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores();
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseMigrationsEndPoint();
}
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.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller= Players}/{action=Index}/{id?}");
app.MapRazorPages();
app.Run();
}
}
}
Код: Выделить всё
{
"ConnectionStrings": {
"DefaultConnection": "Server=User;Database=Players;User Id=Ammadlogin;Password=yellowpass;Encrypt=True;TrustServerCertificate=True;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... in-asp-net