Commit 843e9942 authored by Yrin Leung's avatar Yrin Leung Committed by Savorboard

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

parent 36ee097a
......@@ -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);
}
}
}
......
......@@ -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);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment