hunterlan
hunterlan
CC#
Created by hunterlan on 8/27/2024 in #help
Blazor Static SSR - redirect after form submission
All right, the fix for this solution is remove NavigationManager from try...catch, because it navigates with help of exception, according to this comment on GitHub: https://github.com/dotnet/aspnetcore/issues/53996#issuecomment-1971734784
8 replies
CC#
Created by hunterlan on 8/27/2024 in #help
Blazor Static SSR - redirect after form submission
Microsoft.AspNetCore.Components.NavigationException: Exception of type 'Microsoft.AspNetCore.Components.NavigationException' was thrown.
8 replies
CC#
Created by hunterlan on 1/10/2024 in #help
Unable to set property 'onsubmit' on object of type
got it, thanks!
6 replies
CC#
Created by hunterlan on 1/10/2024 in #help
Unable to set property 'onsubmit' on object of type
Nice, it's fixed, but. Why does it matter?
6 replies
CC#
Created by hunterlan on 12/12/2023 in #help
xUnit: Can't assert exceptions
yep, and I realised that I should created an Endpoint class in test, not in constructor, thanks!
6 replies
CC#
Created by hunterlan on 12/12/2023 in #help
xUnit: Can't assert exceptions
public async Task<IpAnalysisResult> GetReport(string ipAddress, CancellationToken? cancellationToken)
{
var request = new RestRequest($"/{ipAddress}").AddHeader("x-apikey", ApiKey);

RestResponse restResponse;

if (cancellationToken is not null)
{
restResponse = await Client.ExecuteGetAsync(request, cancellationToken.Value);
}
else
{
restResponse = await Client.ExecuteGetAsync(request);
}

if (restResponse is { IsSuccessful: true})
{
var resultJsonDocument = JsonDocument.Parse(restResponse.Content!);
var result = resultJsonDocument.RootElement.GetProperty("data").Deserialize<IpAnalysisResult>(_jsonSerializerOptions)!;
return result;
}

HandleError(restResponse.Content!);
return new IpAnalysisResult();
}
public async Task<IpAnalysisResult> GetReport(string ipAddress, CancellationToken? cancellationToken)
{
var request = new RestRequest($"/{ipAddress}").AddHeader("x-apikey", ApiKey);

RestResponse restResponse;

if (cancellationToken is not null)
{
restResponse = await Client.ExecuteGetAsync(request, cancellationToken.Value);
}
else
{
restResponse = await Client.ExecuteGetAsync(request);
}

if (restResponse is { IsSuccessful: true})
{
var resultJsonDocument = JsonDocument.Parse(restResponse.Content!);
var result = resultJsonDocument.RootElement.GetProperty("data").Deserialize<IpAnalysisResult>(_jsonSerializerOptions)!;
return result;
}

HandleError(restResponse.Content!);
return new IpAnalysisResult();
}
6 replies
CC#
Created by hunterlan on 12/6/2023 in #help
No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
OK, I solved this. I don't know why I added parameter "jwt" in
.AddJwtBearer("jwt", o =>
.AddJwtBearer("jwt", o =>
, but I removed it and it starts to work correctly.
4 replies
CC#
Created by hunterlan on 12/6/2023 in #help
No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
There's Program.cs file:
using System.Text;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using TubeGram.API.Helpers;

var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration;
// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddDbContext<ApplicationContext>(opt => opt.UseSqlServer(config.GetSection("ConnectionString").Value));
builder.Services.AddAuthentication(a =>
{
a.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
a.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
a.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer("jwt", o =>
{
o.TokenValidationParameters = new TokenValidationParameters
{
ValidIssuer = config["Jwt:Issuer"],
ValidAudience = config["Jwt:Audience"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(config["Jwt:Key"]!)),
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true
};
});

var app = builder.Build();

using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationContext>();
// use context
dbContext.Database.EnsureCreated();
}

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
using System.Text;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using TubeGram.API.Helpers;

var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration;
// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddDbContext<ApplicationContext>(opt => opt.UseSqlServer(config.GetSection("ConnectionString").Value));
builder.Services.AddAuthentication(a =>
{
a.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
a.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
a.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer("jwt", o =>
{
o.TokenValidationParameters = new TokenValidationParameters
{
ValidIssuer = config["Jwt:Issuer"],
ValidAudience = config["Jwt:Audience"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(config["Jwt:Key"]!)),
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true
};
});

var app = builder.Build();

using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationContext>();
// use context
dbContext.Database.EnsureCreated();
}

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
4 replies
CC#
Created by hunterlan on 7/19/2023 in #help
❔ Blazor Server: "This localhost page can't be found"
using EngineDatabase.Presentation.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();

builder.Services.AddSingleton<EngineService>();

var app = builder.Build();

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.MapBlazorHub();
app.MapFallbackToPage("/_Host");

app.Run();
using EngineDatabase.Presentation.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();

builder.Services.AddSingleton<EngineService>();

var app = builder.Build();

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.MapBlazorHub();
app.MapFallbackToPage("/_Host");

app.Run();
5 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
But they have a lot of problem not only with Docker xD
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
It's MUCH better than it was 3 years ago, I got a lot of pain trying to understand how to connect two apache containters between each others
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
P - priorities
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
Soon or later they will fix some issues and add missing features It's not so simple I'd like to contribute, but I'm not sure that I can do that
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
On this project for me it takes couple seconds, but I only started, so... Everything can change :DD
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
Yeah, but is it possible to track a process inside docker contrainer for VS?
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
If you have a limited configuration then yes But if you have a good PC, I think it really doesn't matter
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
I guess Microsoft should add it to the documentation, because it confuse a little bit
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
I just even haven't thought that Docker doesn't support Hot Reload, my bad catfacepalm I guess we can close it
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
I got it As I understood, I can't do hot reload while I work with Docker and I should use other options, correct?
67 replies
CC#
Created by hunterlan on 7/9/2023 in #help
❔ VS 2022 Hot Reload disabled
what do you mean?
67 replies