0

I don't know if what i want to do is possible, but I have a JavaScript library i would like to use in the Server end of my Blazor app. Specifically in a service class.

My Blazor app has 2 environments, a Client and a Server. I am able to call my JavaScript functions on the client end using wwwroot/index.html and a blazor component, but i'm not sure how to go about doing it in the Server end. A lot of the documentation suggest providing the JavaScript function in Pages/_Host.cshtml but my project doesn't have (it has only Pages/_Layout.cshtml)

Any help is appreciated!

1 Answer 1

1

If you have a wwwroot/index.html and you don't have Pages/_Host.cshtml means you are using Blazor WASM project hosted by a Server project but the app code doesn't run on the server. It runs only on the browser.

If you want to use a JS library on the Server project you need to use nodejs and INodeServices. You can read this post to know how to use it : https://www.c-sharpcorner.com/article/nodeservices-where-javascript-and-net-meet-back-on-the-other-side/

INodeServices is now obsolete and there isn't replacement but you can still use it. Or you can choose to use Javascript.NodeJS instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.