Browse Source

fix Net Core 3.0,Dashboard Can't Load Js And Css. (#407)

master
Yrin Leung 5 years ago
committed by Savorboard
parent
commit
843e99420d
2 changed files with 10 additions and 10 deletions
  1. +4
    -3
      src/DotNetCore.CAP/Dashboard/CombinedResourceDispatcher.cs
  2. +6
    -7
      src/DotNetCore.CAP/Dashboard/EmbeddedResourceDispatcher.cs

+ 4
- 3
src/DotNetCore.CAP/Dashboard/CombinedResourceDispatcher.cs View File

@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Reflection;
using System.Threading.Tasks;

namespace DotNetCore.CAP.Dashboard
{
@@ -22,14 +23,14 @@ namespace DotNetCore.CAP.Dashboard
_resourceNames = resourceNames;
}

protected override void WriteResponse(DashboardResponse response)
protected override async Task WriteResponse(DashboardResponse response)
{
foreach (var resourceName in _resourceNames)
{
WriteResource(
await WriteResource(
response,
_assembly,
$"{_baseNamespace}.{resourceName}");
$"{_baseNamespace}.{resourceName}").ConfigureAwait(false);
}
}
}

+ 6
- 7
src/DotNetCore.CAP/Dashboard/EmbeddedResourceDispatcher.cs View File

@@ -30,22 +30,21 @@ namespace DotNetCore.CAP.Dashboard
}
}

public Task Dispatch(DashboardContext context)
public async Task Dispatch(DashboardContext context)
{
context.Response.ContentType = _contentType;
context.Response.SetExpire(DateTimeOffset.Now.AddYears(1));

WriteResponse(context.Response);
await WriteResponse(context.Response).ConfigureAwait(false);

return Task.FromResult(true);
}

protected virtual void WriteResponse(DashboardResponse response)
protected virtual Task WriteResponse(DashboardResponse response)
{
WriteResource(response, _assembly, _resourceName);
return WriteResource(response, _assembly, _resourceName);
}

protected void WriteResource(DashboardResponse response, Assembly assembly, string resourceName)
protected async Task WriteResource(DashboardResponse response, Assembly assembly, string resourceName)
{
using (var inputStream = assembly.GetManifestResourceStream(resourceName))
{
@@ -55,7 +54,7 @@ namespace DotNetCore.CAP.Dashboard
$@"Resource with name {resourceName} not found in assembly {assembly}.");
}

inputStream.CopyTo(response.Body);
await inputStream.CopyToAsync(response.Body).ConfigureAwait(false);
}
}
}

Loading…
Cancel
Save