ну конечно, кто будет коннект метод то вызывать? :/ а потом спрашиваю, почему же у меня ничего не работает? все, починила

This commit is contained in:
ekallin 2024-04-07 00:13:50 +03:00
parent ceb0ca6390
commit b393856069
4 changed files with 28 additions and 27 deletions

View File

@ -9,9 +9,10 @@ namespace SushiBarClientApp
{
private static readonly HttpClient _client = new();
public static ClientViewModel? Client { get; set; } = null;
public static void Connect(IConfiguration configuration)
{
_client.BaseAddress = new Uri("http://localhost:5262/");
_client.BaseAddress = new Uri(configuration["IPAddress"]);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}

View File

@ -1,10 +1,9 @@
using SushiBarClientApp;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
APIClient.Connect(builder.Configuration);
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
@ -12,16 +11,11 @@ if (!app.Environment.IsDevelopment())
// 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=Home}/{action=Index}/{id?}");
app.Run();

View File

@ -6,6 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="logs/SushiBarRestApi.log" />
<appendToFile value="true" />
@ -13,4 +15,6 @@
<level value="TRACE" />
<appender-ref ref="RollingFile" />
</root>
</log4net>
</log4net>
</configuration>