Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UseCapDashboard is now internal #1244

Closed
jirisykora83 opened this issue Nov 28, 2022 · 16 comments
Closed

UseCapDashboard is now internal #1244

jirisykora83 opened this issue Nov 28, 2022 · 16 comments
Labels

Comments

@jirisykora83
Copy link

UseCapDashboard is mark as internal with 7.0.0 is that intended. If so, how it should be replaced?

@yang-xiaodong
Copy link
Member

The dashboard middleware will register automatically in ASP.NET Core, Users don't need to register it.

@jirisykora83
Copy link
Author

Then after upgrading to v7 and removing UseCapDashboard from startup I wont access dashboard anymore (I literally change just cap nugget package version and remove this one line).

@yang-xiaodong
Copy link
Member

services.AddCap(x =>
{
    // Add this line
    x.UseDashboard();
}

@jirisykora83
Copy link
Author

yes this is something what I already have even with 6.2.1 because we use custom path and basic authentication because azureAD do not work for as and basic auth is fine for our usecase).

@yang-xiaodong yang-xiaodong reopened this Nov 30, 2022
@yang-xiaodong
Copy link
Member

#792

In your case, is the basic auth middleware registration sequence before UseCapDashboard?

@jirisykora83
Copy link
Author

I don't in 6.2.1. With 7.0.0 a cannot call UseCapDashboard as it is internal. If you mean UseDashboard inside AddCap I try it move AddAuthentication before AddCap but is seems like it still not work for me.

I also try remove authentication and my custom path but i am still not able to reach /cap.

On same app I hosting blazor app which somehow could collide with way the cap handle its dashboard?

Maybe it could be nice have some default logging in CapStartupFilter just to make sure it is actually called?

@yang-xiaodong
Copy link
Member

Can you provide a reproducible example repository for us ?

@ggjnone
Copy link

ggjnone commented Dec 7, 2022

Same issue here, I have a blazor server app and with previous version it worked well, finding the cap route for the Dashboard. With 7.0.0 it stopped working. Same configurations its just the UseCapDashboard was being called explicitly. And using .Net6.

@yang-xiaodong
Copy link
Member

Fixed in 7.0.1

@jirisykora83
Copy link
Author

It still not works i create default blazor wasm app (with checked option for hosted in asp.net)

Put this in top section (literally only change what i made - not sure if it worth creating github repo for that).

builder.Services.AddCap(x =>
{
	x.UseInMemoryStorage();
	x.UseInMemoryMessageQueue();

	x.UseDashboard(opts =>
	{
		opts.PathMatch = "/cap-dashboard";
	});
});

packages in "server" project

  <ItemGroup>
    <PackageReference Include="DotNetCore.CAP" Version="7.0.1" />
    <PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="7.0.1" />
	<PackageReference Include="DotNetCore.CAP.MongoDB" Version="7.0.1" />
	<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="7.0.1" />
	<PackageReference Include="DotNetCore.CAP.Dashboard" Version="7.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.1" />
    <PackageReference Include="Savorboard.CAP.InMemoryMessageQueue" Version="7.0.0" />
  </ItemGroup>

And dashboard route serves just blazor app.

image

just in case it's not use custom path but it same.
image

@yang-xiaodong
Copy link
Member

I found out that due to my browser client side 301 redirect caching, the issue wasn't really fixed in 7.0.1, it will be fixed in 7.0.2.

Blazor wasm is not supported!

@jirisykora83
Copy link
Author

Did you means cap cannot be use with wasm hosting from v7.0+? Because it was working with v6.

@yang-xiaodong
Copy link
Member

Yes, Blazor wasm It runs in the browser, it does not have the ASP.NET Core environment required by CAP dashboard.

Blazor wasm sdk is Microsoft.NET.Sdk.BlazorWebAssembly not contains Microsoft.AspNetCore.App framework

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

Blazor server sdk is Microsoft.NET.Sdk.Web

<Project Sdk="Microsoft.NET.Sdk.Web">

If CAP Dashboard is referenced in the Blazor WASM project, this compilation error will occur

There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm

@jirisykora83
Copy link
Author

Ok i understand it cannot runs in browser i am not sure if there is any problem in same asp instance serve/host blazor app and cap.

I tried 7.0.2 (last nuget as now) and dashboard endpoint is not reachable but it shows just white page as it is not loading any assets.

image

@yang-xiaodong
Copy link
Member

yang-xiaodong commented Jan 10, 2023

I created a new blazor server app to test it works ok.

Are you map the fallback route ? see #1256

@jirisykora83
Copy link
Author

jirisykora83 commented Jan 10, 2023

I use endpoints.MapFallbackToAreaPage("{*path:nonfile}", "/_FrontendHost", "Frontend"); as it should be same as your example but it not works for me.

Now a was able to solve this as in my case i use asp to host multiple blazor app. And as last entry in startup.cs I have

app.Map(
	"",
	builder =>
	{
		builder.UseRouting();
		builder.UseEndpoints(endpoints =>
		{
			// Fallback for blazor front-end
			endpoints.MapFallbackToAreaPage("{*path:nonfile}", "/_FrontendHost", "Frontend");
		});
	});

which for whatever reason causes this. So, if anybody have same issue (mostly likely not) i just change it to this:

app.MapWhen(
	x => !x.Request.Path.StartsWithSegments(CapConst.CapDashboardPath)
	builder =>
	{
		builder.UseRouting();
		builder.UseEndpoints(endpoints =>
		{
			// Fallback for blazor front-end
			endpoints.MapFallbackToAreaPage("{*path:nonfile}", "/_FrontendHost", "Frontend");
		});
	});

Thanks for your help i like your project :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants