Problems Referencing Static Javascript Files In Wwwroot - .net Core 2.2 Signalr
Solution 1:
I would recommend you change a folder name and replace a url like this
<scriptsrc="~/lib/signalr/dist/browser/signalr.js"></script><scriptsrc="~/js/chat.js"></script>
Check this link too
Note: make sure your code is place at bottom of the page
Solution 2:
1st, you should make sure your app (kestrel server) support static file (app.UseStaticFiles()
in Configurate method in startup.cs
) , and make sure the Microsoft.AspNetCore.Hosting.IHostingEnvironment.WebRoot
is to a folder in your disk(normally it point to $"{Dictory.GetCurrentDirectory()}/wwwroot/"
).
2st, make sure your signalr.js is in WebRoot
folder (so it can be serve), and note the wwwroot
folder is your root path eg ~/
, which mean your your js file is in wwwroot/lib/signalr/signalr.js
the correct path for razor's script Tag Helper is <script src="~/lib/signalr/signalr.js"></script>
.
Solution 3:
<scriptsrc="~/wwwroot/lib/@@AspNetCore/signalr/dist/browser/signalr.js"></script><scriptsrc="~/wwwroot/js/chat.js"></script>
Replace with this
@sectionScripts {
<scriptsrc="~/lib/@@AspNetCore/signalr/dist/browser/signalr.js"></script><scriptsrc="~/js/chat.js"></script>
}
Post a Comment for "Problems Referencing Static Javascript Files In Wwwroot - .net Core 2.2 Signalr"