Web front-end framework is emerging nowadays. We all know about the giant names, such as Angular, React, and Vue. Angular provides two-way data binding when React has the one-direction data flow and Vue.js has both of them.
What is Vue Js?
Vue is a progressive framework for building modern user interfaces. It is suitable for SPA (Single Page Applications) which is a combination of modern tools and libraries. It is a JavaScript framework.
Why does the developer choose Vue.js?
Vue is an approachable, versatile, and performant JavaScript framework. It helps to build a more maintainable and testable code base.
Install Vue.js globally.
- npm install -g @vue/cli
Check version of Vue.js
- vue --version
Install .NET Core 3 SDK
Download the latest version of this SDK and install it.

Let's start with .NET Core 3 and Vue.js.
Create ASP.NET Core 3 web application project using API template.

It takes a few minutes to create an API project. Once completed, go to the package manager console and write the following command. Make sure the selected project is API project. After that, it will create one folder called client-app.
- vue create client-app

Add Microsoft.AspNetCore.SpaServices.Extensions package from NuGet Package or just replace the csproj file with below one. So, it will automatically add this package.
- <Project Sdk="Microsoft.NET.Sdk.Web">
- <PropertyGroup>
- <TargetFramework>netcoreapp3.0</TargetFramework>
- <SpaRoot>client-app\</SpaRoot>
- <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
- <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
- <TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
- <IsPackable>false</IsPackable>
- </PropertyGroup>
- <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
- <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
- <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />
- <ItemGroup>
- <DistFiles Include="$(SpaRoot)dist\**" />
- <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
- <RelativePath>%(DistFiles.Identity)</RelativePath>
- <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
- </ResolvedFileToPublish>
- </ItemGroup>
- </Target>
- <ItemGroup>
- <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.0.0-preview6.19307.2" />
- </ItemGroup>
- <ItemGroup>
- <Content Remove="$(SpaRoot)**" />
- <None Remove="$(SpaRoot)**" />
- <None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
- </ItemGroup>
- <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
- <Exec Command="node --version" ContinueOnError="true">
- <Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
- </Exec>
- <Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
- <Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
- <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
- </Target>
- </Project>
Let us now inject the middleware at startup file and add connection.cs file for port forwrding.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.AspNetCore.HttpsPolicy;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Hosting;
- using Microsoft.Extensions.Logging;
- using VueDemoWithAsp.NetCore.VueCoreConnection;
- namespace VueDemoWithAsp.NetCore
- {
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- }
- public IConfiguration Configuration { get; }
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddControllers();
- // connect vue app - middleware
- services.AddSpaStaticFiles(options => options.RootPath = "client-app/dist");
- }
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
- {
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- else
- {
- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
- app.UseHsts();
- }
- app.UseHttpsRedirection();
- app.UseRouting();
- app.UseAuthorization();
- app.UseEndpoints(endpoints =>
- {
- endpoints.MapControllers();
- });
- // use middleware and launch server for Vue
- app.UseSpaStaticFiles();
- app.UseSpa(spa =>
- {
- spa.Options.SourcePath = "client-app";
- if (env.IsDevelopment())
- {
- spa.UseVueDevelopmentServer();
- }
- });
- }
- }
- }



liu yongshuaiPosted Nov 4, 2019, 8:04 PM
How to run project on server
rogerio rogerioPosted Oct 23, 2019, 12:11 PM
I have one question, how do i create an app vue distribution. I try. and recieve error . npm : - Building for production...No linha:1 caractere:1+ npm run build + ~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (- Building for production...:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
rogerio rogerioPosted Oct 23, 2019, 12:11 PM
Nice, toppppppp.
mihir tankPosted Jun 26, 2019, 3:50 AM
Superb Article
Mahesh VermaPosted Jun 25, 2019, 11:19 PM
Great article, keep it up :-)
Ankur MistryPosted Jun 25, 2019, 11:09 PM
Great Article Smiten Kalathiya keep it up.
mitul patelPosted Jun 25, 2019, 11:59 AM
Thanks smiten nice explain with example
Keval ThummarPosted Jun 25, 2019, 11:56 AM
Thank you smiten for spreading your knowledge.
Mahesh ChandPosted Jun 25, 2019, 11:19 AM
Thank you, Smiten. Best