
*By Sean Erick C. Ramones, Vue SME | JavaScript/TypeScript SME*
Sean Erick C. Ramones
Introduction
Many companies still rely on traditional ASP.NET MVC applications that have matured over time. However, with the need for richer user experiences, it's important to consider modern frontend technologies like Vue.js. This report explores how Vue.js can be integrated into an ASP.NET MVC (non-Core) application, highlighting practical approaches and relevant tooling support such as Webpack.
Tooling Considerations
Challenges
Ideal Approches on VueJS integration
Approach 1: Embedding Vue in Razor Views (Widget-Based Enhancements)
For small enhancements or interactive UI components:
_Layout.cshtml:<script src="https://cdn.jsdelivr.net/npm/vue@3"></script>
.cshtml:<div id="greeting">
Hello, {{ name }}!
</div>
<script>
Vue.createApp({
data() {
return {
name: '@ViewBag.UserName'
};
}
}).mount('#greeting');
</script>
This method is ideal for adding interactivity without complex tooling.
Approach 2: Vue with Build Tools (Webpack or Vite)
To integrate more sophisticated components:
ClientApp/:npm init vue@latest
cd ClientApp
npm install
npm run build
wwwroot/js/).<script src="~/js/app.js"></script>
<link href="~/js/style.css" rel="stylesheet">
More in-depth:
webpack.config.js to compile .vue files and output them to the Scripts or dist folder.BundleConfig.cs to manage generated JS bundles.// Example webpack.config.js
const path = require('path');
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, 'wwwroot/dist'),
filename: 'bundle.js'
},
module: {
rules: [
{ test: /\.vue$/, loader: 'vue-loader' },
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ }
]
},
resolve: {
alias: { 'vue$': 'vue/dist/vue.esm.js' },
extensions: ['*', '.js', '.vue', '.json']
}
};
This setup allows full use of Vue SFCs (Single File Components) while maintaining ASP.NET MVC routing.
Approach 3: Serve Vue as a SPA Shell in MVC
You can let ASP.NET MVC serve only a single entry point (e.g., Home/Index), and Vue handles routing and rendering:
Index.cshtml to serve app shell:<div id="app"></div>
<script src="~/dist/app.js"></script>
This is ideal for teams transitioning from MVC to full SPAs gradually.
Considerations
Webpack or Vite depending on scope.Conclusion Integrating Vue.js into classic ASP.NET MVC apps enables modern UX features and more maintainable frontends without abandoning existing server-side logic. Whether you're enhancing specific components or planning a full frontend upgrade, Vue offers a scalable path toward modernization.
Author’s note: This is also part of my research wherein I can try to help the Voky team migrate to using modern JS frameworks from the old JQuery , and I am currently discussing with one of the devs on how to incrementally do this while the rest of the team take on more priority tasks 🍍.
Resources (pasting these here for reference with the other devs)