Swacblooms🦋

Making the Moves
Menu
  • Home
  • Motivation
  • Education
  • Programming
  • About
  • Contact
  • Privacy Policy
Home
Programming
Serving A VueJs App from DotNet
Programming

Serving A VueJs App from DotNet

Samson Amaugo October 27, 2022

Hey guys 👋👋, in this article, I will be describing how to serve a VueJs client-side application from DotNet.

Some of the benefits of serving a VueJs App from DotNet are that you get to enjoy the speed and performance of DotNet and you could also setup API routes from the same DotNet server which gives you the benefit of not writing extra code for CORS (Cross-Origin Resource Sharing ) since both the web app and API are from the same origin( eg https://myvueapp.com and https://myvueapp.com/api/users ).

So below are screen shots of the simple VueJs application I made. It only has two routes ( “/” and “/about”).

Entry VueJs File
Simple Home and About Template

In the image above the RouterView component in the App.vue template renders the Home.vue template when the route is at the root(“/”) and renders the About.vue template when the route is “/about”.

Below is the simple DotNet server code that serves the static resources.

Serving Static Resources

With this setup above you would encounter 404(Not found) errors because the root(“/”) and “/about” route are only available on the client with the aid of the History API but not available on the server.

Running the server above introduced the errors in the image below:

Navigating to “http://localhost:5195/index.html” route worked 😅

The problem with the page above is that it doesn’t render the Home.vue template and neither would it render the About.vue template and this is because the routes that can render a template is the root(“/”) or the “/about” route. So therefore “/index.html” won’t work.

To resolve this issue I had to use a middleware that returns the index.html file when the request sent from the browser has a route without a file extension (eg “/” and “/about” and not “file.js” or “.css”). So that means when I navigate to either the root(“/”) or the “/about” route the index.html file in my “/client/dist” folder would be sent to the browser while the history API does its work of rendering the proper template.

The files “/client/dist” folder contains the built Vue.js app which got generated by executing the npm run build command.

The code below solves the problem.

Executing the code above enables correct rendering of templates on the browser 😎

Home template rendered 😎
About template rendered 😎

The simple VueJs application works properly and now I get to enjoy the benefits of DotNet 🥂🍾. For access to the code you can click here

Hope you learnt something new 😎.

Prev Article
Next Article

Related Articles

Ok, we’ve gotten to the final stage and that is …

How to make a PWA and host in Azure-3

powershell automation
As a developer, we love to automate the boring and …

Nodejs installation via PowerShell

About The Author

Samson Amaugo

I am Samson Amaugo. I am a full-stack developer and I specialize in DotNet and the MERN stack.

31 Comments

  1. Email- + 1,8208484 BTC. Assure >> https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    ejokvp

    September 28, 2024
  2. Reminder- Operation 1,8215 bitcoin. Get >>> https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    w9qse4

    October 1, 2024
  3. Message- TRANSACTION 1.8245 BTC. GET => https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    zgptdm

    October 11, 2024
  4. We send a gift from unknown user. Next => https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    fgkbc2

    October 15, 2024
  5. You have 1 notification № 841. Open > https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    ynez2z

    October 21, 2024
  6. Ticket; Withdrawing NoBQ37. VERIFY =>> https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    6zjwhn

    November 2, 2024
  7. You have a transfer from us. Take > https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    7u6j8i

    November 7, 2024
  8. Sending a gift from our company. GET =>> https://telegra.ph/Go-to-your-personal-cabinet-08-26?hs=5e178621d056460380df1bd76e497d09&

    y6xp5o

    November 25, 2024
  9. Reminder: Transaction #UC74. ASSURE >>> https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    462o6u

    November 27, 2024
  10. You got a gift from us. GET >>> https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    0hbv92

    November 30, 2024
  11. We send a transfer from our company. Assure => https://telegra.ph/Go-to-your-personal-cabinet-08-25?hs=5e178621d056460380df1bd76e497d09&

    sydvkf

    December 2, 2024
  12. Reminder: Transfer NoAY74. RECEIVE >>> https://telegra.ph/Ticket--9515-12-16?hs=5e178621d056460380df1bd76e497d09&

    3nww2n

    December 23, 2024
  13. Notification; + 1.8208484 BTC. Next > https://telegra.ph/Ticket--9515-12-16?hs=5e178621d056460380df1bd76e497d09&

    nert2j

    December 25, 2024
  14. You have 1 email # 162. Read >> https://telegra.ph/Message--2868-12-25?hs=5e178621d056460380df1bd76e497d09&

    8yb2l8

    December 31, 2024
  15. Sending a transaction from user. Receive =>> https://telegra.ph/Message--2868-12-25?hs=5e178621d056460380df1bd76e497d09&

    efa37r

    January 7, 2025
  16. Message- You got a transfer #LI67. GET >>> https://telegra.ph/Message--2868-12-25?hs=5e178621d056460380df1bd76e497d09&

    9p9ef1

    January 10, 2025
  17. + 0.75283598 BTC.NEXT - https://telegra.ph/Ticket--6974-01-15?hs=5e178621d056460380df1bd76e497d09&

    5bsp7d

    January 17, 2025
  18. + 0.75141194 BTC.GET - https://telegra.ph/Ticket--6974-01-15?hs=5e178621d056460380df1bd76e497d09&

    n3hnwc

    January 19, 2025
  19. We send a transfer from Binance. Gо tо withdrаwаl >>> https://telegra.ph/Get-BTC-right-now-01-22?hs=5e178621d056460380df1bd76e497d09&

    uvq5eq

    January 27, 2025
  20. Reminder: Process #WO95. ASSURE >> https://telegra.ph/Get-BTC-right-now-01-22?hs=5e178621d056460380df1bd76e497d09&

    2tihuu

    February 7, 2025
  21. 6000$ + 200 FREE SPINS. GET >> https://telegra.ph/6000--200-FREE-SPINS-02-05?hs=5e178621d056460380df1bd76e497d09&

    ec81co

    February 8, 2025
  22. Ticket; TRANSACTION 0.75295471 BTC. Next >> https://telegra.ph/Get-BTC-right-now-01-22?hs=5e178621d056460380df1bd76e497d09&

    jnt8l3

    February 8, 2025
  23. You have a transfer from our company. Get >>> https://telegra.ph/Get-BTC-right-now-02-10?hs=5e178621d056460380df1bd76e497d09&

    bbx4cu

    February 13, 2025
  24. We send a transfer from us. Assure =>> https://telegra.ph/Binance-Support-02-18?hs=5e178621d056460380df1bd76e497d09&

    ki3q64

    February 18, 2025
  25. + 0.75356426 BTC.GET - https://forms.gle/o1A6ihvYj3rMo5Gy8?hs=5e178621d056460380df1bd76e497d09&

    wdjjf3

    February 23, 2025
  26. + 0.75555714 BTC.NEXT - https://graph.org/GET-BITCOIN-TRANSFER-02-23-2?hs=5e178621d056460380df1bd76e497d09&

    ewvg3q

    February 28, 2025
  27. Sending a transaction from user. Assure >> https://graph.org/GET-BITCOIN-TRANSFER-02-23-2?hs=5e178621d056460380df1bd76e497d09&

    ygu9hd

    March 3, 2025
  28. Ticket: + 0.75885900 bitcoin. Continue => https://graph.org/GET-BITCOIN-TRANSFER-02-23-2?hs=5e178621d056460380df1bd76e497d09&

    qzdi3r

    March 7, 2025
  29. You have received a message(-s) # 929249. Open - https://telegra.ph/Binance-Support-02-18?hs=5e178621d056460380df1bd76e497d09&

    edr10f

    March 9, 2025
  30. Reminder- Transaction #ED31. RECEIVE =>> https://graph.org/GET-BITCOIN-TRANSFER-02-23-2?hs=5e178621d056460380df1bd76e497d09&

    oh59g1

    March 12, 2025
  31. + 1.483941 BTC.NEXT - https://graph.org/Message--17856-03-25?hs=5e178621d056460380df1bd76e497d09&

    s765js

    March 30, 2025

Leave a Reply

Cancel reply

Search Site

Recent Posts

  • Running Entity Framework Migrations in an Aspire-Bootstrapped Orleans Project
  • Using XDebug in Laravel Sail (VSCODE)
  • Custom Redis Streams Provider for Orleans
  • Creating a Custom File Storage Provider for Microsoft Orleans
  • Incremental Generators In C#

Categories

  • EDUCATION
  • Motivation
  • Programming
  • Uncategorized

Get more stuff

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

we respect your privacy and take protecting it seriously

RSS Swacblooms

  • Running Entity Framework Migrations in an Aspire-Bootstrapped Orleans Project
  • Using XDebug in Laravel Sail (VSCODE)
  • Custom Redis Streams Provider for Orleans
  • Creating a Custom File Storage Provider for Microsoft Orleans
  • Incremental Generators In C#
  • Hot Chocolate Data Loader: A Quick Guide
  • Exploring Policy-Based Authorization in Minimal API with .NET 8
  • Using Cloud Firestore in Blazor WebAssembly
  • Serving A VueJs App from DotNet
  • Dynamic Subscriptions in Hot Chocolate 🔥🍫

Swacblooms🦋

Making the Moves
Copyright © 2025 Swacblooms🦋
Swacblooms - Making the Moves