ASP.NET Core Snippets for Visual Studio Code


Image result for visual studio code logoI’m currently creating a new course on how to use Visual Studio Code with ASP.NET Core. While I rely on yeoman for project scaffolding and some file scaffolding, I wanted to get some of the snippets I’ve grown used to having in the full Visual Studio.

I found a project called ASP.NET Core Snippets to my excitement, but it only had snippets for some of the main files in your project. Not action snippets or razor snippets. So at 4am last night I wrote a Visual Studio Code extension to add some of these snippets.

So far, it only has a handful of snippets that my 4am brain knew I wanted:

C# Snippets:

mvc6-action: Creates an MVC6 Action that returns a view.
mvc6-get: Creates an MVC6 Action that Implements a basic GET.
mvc6-post: Creates an MVC6 Action that Implements a basic POST.
mvc6-put: Creates an MVC6 Action that Implements a basic PUT.
mvc6-delete: Creates an MVC6 Action that Implements a basic DELETE.
mvc6-controller: Creates an MVC6 Controller for views.
mvc6-apicontroller: Creates an MVC6 Controller for an API that implements all four basic verbs.
ef-dbcontext: Creates an Entity Framework Core DbContext class.

Razor Snippets:

razor-inject: Generates an @inject block.
razor-environment: Generates an environment block.
razor-raw: Generates an @Html.Raw block.

You can get the snippet from the marketplace here:

http://shawnw.me/aspnetcoresnippets

or by installing them directly in Visual Studio Core:

install

I’d love anyone that has snippets that would be helpful or knows a snippet they’d like me to build. Fork the repo and send me a pull-request, or just add an issue to the github repo:

http://github.com/shawnwildermuth/aspnetcore-snippets


Bootstrap 4 is Here!

After a long development cycle, Bootstrap has been completely re-written to improve performance and be more consistent. Learn Bootstrap 4 now with my Wilder Minds course:

Enroll Today


Shawn
Shawn Wildermuth
Author, Teacher, and Coach




My Courses

Wilder Minds Training
Vue.js by Example (Now Available)
Bootstrap 4 by Example
Intro to Font Awesome 5 (Free Course)
Pluralsight
Less: Getting Started (Coupon Available)
Building a Web App with ASP.NET Core, MVC6, EF Core, Bootstrap and Angular (updated for 2.1)
Using Visual Studio Code for ASP.NET Core Projects
Implementing ASP.NET Web API
Web API Design

Application Name WilderBlog Environment Name Production
Application Ver v4.0.30319 Runtime Framework x86
App Path D:\home\site\wwwroot\ Runtime Version .NET Core 4.6.26919.02
Operating System Microsoft Windows 10.0.14393 Runtime Arch X86