All Projects → soukoku → Aspnetcore Vue

soukoku / Aspnetcore Vue

Licence: mit
Sample setup on using asp.net core 2.1 + vue cli 3 in one project. This sample is deprecated and rolled into https://github.com/soukoku/AspNetCore.SpaServices.VueCli

Projects that are alternatives of or similar to Aspnetcore Vue

Nopcommerce
The most popular open-source eCommerce shopping cart solution based on ASP.NET Core
Stars: ✭ 6,827 (+21922.58%)
Mutual labels:  aspnetcore, aspnet
Csla
A home for your business logic in any .NET application.
Stars: ✭ 865 (+2690.32%)
Mutual labels:  aspnetcore, aspnet
aspnet-api-versioning
Provides a set of libraries which add service API versioning to ASP.NET Web API, OData with ASP.NET Web API, and ASP.NET Core.
Stars: ✭ 2,396 (+7629.03%)
Mutual labels:  aspnetcore, aspnet
X.Extensions.Logging.Telegram
Telegram logging provider
Stars: ✭ 32 (+3.23%)
Mutual labels:  aspnetcore, aspnet
Aspnet Core Jwt Authentication Api
ASP.NET Core 2.2 JWT Authentication API
Stars: ✭ 272 (+777.42%)
Mutual labels:  aspnetcore, aspnet
LeXun.Security.OAuth
用于 Asp.Net 和 Asp.Net Core 的OAuth2社交身份验证提供程序。支持支付宝,QQ,微信,百度等第三方登录
Stars: ✭ 19 (-38.71%)
Mutual labels:  aspnetcore, aspnet
KissLog.Sdk
KissLog is a lightweight and highly customizable logging framework for .NET applications
Stars: ✭ 33 (+6.45%)
Mutual labels:  aspnetcore, aspnet
Identity.dapper
Identity package that uses Dapper instead EntityFramework for use with .NET Core
Stars: ✭ 234 (+654.84%)
Mutual labels:  aspnetcore, aspnet
abp-push
Push Notification System for ASP.NET Boilerplate
Stars: ✭ 16 (-48.39%)
Mutual labels:  aspnetcore, aspnet
run-aspnet-grpc
Using gRPC in Microservices for Building a high-performance Interservice Communication with .Net 5. See gRPC Microservices and Step by Step Implementation on .NET Course w/ discount->
Stars: ✭ 82 (+164.52%)
Mutual labels:  aspnetcore, aspnet
AspNetCore.Identity.RavenDB
RavenDB Storage Provider for ASP.NET Core Identity
Stars: ✭ 16 (-48.39%)
Mutual labels:  aspnetcore, aspnet
Nswag
The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
Stars: ✭ 4,825 (+15464.52%)
Mutual labels:  aspnetcore, aspnet
Aspnetcore Vueclimiddleware
Helpers for building single-page applications on ASP.NET MVC Core using Vue Cli or Quasar Cli.
Stars: ✭ 253 (+716.13%)
Mutual labels:  aspnetcore, aspnet
Awesome Microservices Netcore
💎 A collection of awesome training series, articles, videos, books, courses, sample projects, and tools for Microservices in .NET Core
Stars: ✭ 865 (+2690.32%)
Mutual labels:  aspnetcore, aspnet
Blazortable
Blazor Table Component with Sorting, Paging and Filtering
Stars: ✭ 249 (+703.23%)
Mutual labels:  aspnetcore, aspnet
run-aspnet-identityserver4
Secure microservices with using standalone Identity Server 4 and backing with Ocelot API Gateway. Protect our ASP.NET Web MVC and API applications with using OAuth 2 and OpenID Connect in IdentityServer4. Securing your web application and API with tokens, working with claims, authentication and authorization middlewares and applying policies.
Stars: ✭ 159 (+412.9%)
Mutual labels:  aspnetcore, aspnet
React Core Boilerplate
Powerful ASP.NET Core 3 templates with React, true server-side rendering and Docker support
Stars: ✭ 169 (+445.16%)
Mutual labels:  aspnetcore, aspnet
Aspnetcore.identity.mongodb
MongoDB Data Store Adaptor for ASP.NET Core Identity
Stars: ✭ 210 (+577.42%)
Mutual labels:  aspnetcore, aspnet
aspnet-core-3-basic-authentication-api
ASP.NET Core 3.1 - Basic HTTP Authentication API
Stars: ✭ 70 (+125.81%)
Mutual labels:  aspnetcore, aspnet
Aspnet Core 3 Jwt Authentication Api
ASP.NET Core 3.1 JWT Authentication API
Stars: ✭ 443 (+1329.03%)
Mutual labels:  aspnetcore, aspnet

aspnetcore-vue

A sample aspnet project template with these features:

  • asp.net core 2.1 for server-side code
  • vue.js for client-side code (created with cli v3)
  • both live in one project and debugging is done on the aspnet project
  • working HMR in vue app when debugging the aspnet site

Below are the steps used to create this.

Aspnet Core Project

Create a new dotnet core project with aspnet core template.

Then In Startup.cs, add services.AddSpaStaticFiles() in ConfigureServices() method, and app.UseSpaStaticFiles() and app.UseSpa() in Configure() method.

public void ConfigureServices(IServiceCollection services)
{
  services.AddMvc();

  // new addition here
  services.AddSpaStaticFiles(spa =>
  {
    spa.RootPath = @"ClientApp\dist";
  });
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
  // ... other aspnet configuration skipped here

  app.UseStaticFiles();
  app.UseSpaStaticFiles(); // new addition
  app.UseMvc();

  // new addition
  app.UseSpa(spa =>
  {
    if (env.IsDevelopment())
    {
      // change this to whatever webpack dev server says it's running on
      spa.UseProxyToSpaDevelopmentServer("http://localhost:8080");
    }
  });
}

Vue Project

Create a client-side project using vue cli 3 into a folder called ClientApp in the aspnet project folder.

Csproj File

Some edits to the .csproj file are also needed for proper release/publish using dotnet.

The PropertyGroup defines a new variable SpaRoot for use later.

The ItemGroup makes vue's project folder visible in VS but not include in build.

DebugEnsureNodeEnv target installs npm packages if necessary on project builds.

PublishRunWebpack target builds the vue app and include the dist folder in the published files.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <!-- ...default stuff skipped here... -->

  <PropertyGroup>
    <SpaRoot>ClientApp\</SpaRoot>
  </PropertyGroup>

  <ItemGroup>
    <Content Remove="$(SpaRoot)**" />
    <None Include="$(SpaRoot)**" Exclude="$(SpaRoot)dist\**" />
  </ItemGroup>
  
  <Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
    <!-- Ensure Node.js is installed -->
    <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>

  <Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
    <!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm install" />
    <Exec WorkingDirectory="$(SpaRoot)" Command="npm run build" />

    <!-- Include the newly-built files in the publish output -->
    <ItemGroup>
      <DistFiles Include="$(SpaRoot)dist\**" />
      <ResolvedFileToPublish Include="@(DistFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
        <RelativePath>%(DistFiles.Identity)</RelativePath>
        <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
      </ResolvedFileToPublish>
    </ItemGroup>
  </Target>
</Project>

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].