Skip to content

Instantly share code, notes, and snippets.

@Jason446620
Jason446620 / view.razor.cs
Created May 1, 2024 01:39
Blazor app not showing new information after update message via SignalR
public partial class View : ComponentBase
{
[Parameter]
public int DebtorId { get; set; }
private Debtor _debtor = new();
private bool DataLoading = false;
private HubConnection _hub;
protected override async Task OnInitializedAsync()
// Copyright (c) 2024 Sergio Hernandez. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
using System.Security.Cryptography.X509Certificates;
namespace WebApplication2
{
public class CertificateAuthenticationMiddleware
{
private readonly RequestDelegate _next;
private readonly ILogger<CertificateAuthenticationMiddleware> _logger;
public CertificateAuthenticationMiddleware(RequestDelegate next, ILogger<CertificateAuthenticationMiddleware> logger)
const connection = new signalR.HubConnectionBuilder()
.withUrl("/notificationHub")
.configureLogging(signalR.LogLevel.Information)
.build();
connection.start()
.then(function () {
console.log("Connected!");
})
.catch(function (err) {
string basedir = "C:\\Users\\Jason\\Downloads\\BlazorAppWasmAuth-main\\BlazorAppWasmAuth-main\\BlazorAppWasmAuth";//AppDomain.CurrentDomain.BaseDirectory;
WebApplicationOptions options = new()
{
ContentRootPath = basedir,
Args = args,
WebRootPath = Path.Combine(basedir, "wwwroot")
};
var builder = WebApplication.CreateBuilder(options);
var expiration = response.Data.SessionExpirationDate.Value.ToUniversalTime();
// Calculate effective TokenLifetimeInMinutes
var tokenLifetime = (int)expiration.Subtract(DateTime.UtcNow).TotalMinutes + 1;
// Make sure tokenLifetime number > 0
if (tokenLifetime <= 0)
{
tokenLifetime = 5; // SET A DEFAULT VALUE
}
<!DOCTYPE html>
<html>
<head>
<title>DragSort Example</title>
<meta charset="utf-8" />
<style type="text/css">
body { font-family:Arial; font-size:12pt; padding:20px; width:820px; margin:20px auto; border:solid 1px black; }
h1 { font-size:16pt; }
h2 { font-size:13pt; }
ul { margin:0px; padding:0px; margin-left:20px; }
// jQuery List DragSort v0.5.2
(function($) {
$.fn.dragsort = function(options) {
if (options == "destroy") {
$(this.selector).trigger("dragsort-uninit");
return;
}
@page "/"
@using XMagic.Client.Shared
@rendermode @(new InteractiveAutoRenderMode(prerender: false))
<a href="/">index</a>
<a href="/test">test</a>
<div class="flex mx-auto">
<div class="flex flex-col gap-4">
@foreach (var img in _col1)
[2024-07-03T02:00:08.026Z] Information: Normalizing '/hub/shop?nickname=PCTestUser2' to 'https://23p1z4dk-7189.euw.devtunnels.ms/hub/shop?nickname=PCTestUser2'.
signalr.min.js:1 [2024-07-03T02:00:08.027Z] Debug: Starting HubConnection.
signalr.min.js:1 [2024-07-03T02:00:08.027Z] Debug: Starting connection with transfer format 'Text'.
signalr.min.js:1 [2024-07-03T02:00:08.027Z] Debug: Sending negotiation request: https://23p1z4dk-7189.euw.devtunnels.ms/hub/shop/negotiate?nickname=PCTestUser2&negotiateVersion=1.
signalr.min.js:1 [2024-07-03T02:00:09.864Z] Debug: Sending negotiation request: https://jasonp2.service.signalr.net/client/negotiate?hub=mainhub&asrs.op=%2Fhub%2Fshop&nickname=PCTestUser2&negotiateVersion=1&asrs_request_id=KGCTrgQAAAA%3D.
signalr.min.js:1 [2024-07-03T02:00:10.195Z] Debug: Selecting transport 'WebSockets'.
signalr.min.js:1 [2024-07-03T02:00:10.195Z] Trace: (WebSockets transport) Connecting.
signalr.min.js:1 [2024-07-03T02:00:10.349Z] Information: WebSocket connected to wss://jasonp2.serv