Tag Archives: Visual Studio

EF Core Migrations in ASP .NET Core

By Shahed C on November 15, 2018

This is the seventh of a new series of posts on ASP .NET Core. In this post, we’ll be looking at the use of EF Core Migrations for your ASP .NET Core web apps. (Normally, I would publish these blog posts on a weekend to allow developers to read it the following week. However, it’s Thanksgiving next week in the US, so I’m publishing this one a few days earlier.) 

ASPNETCoreLogo-300x267

Entity Framework Core

Entity Framework is Microsoft’s ORM (Object-Relational Mapper) and EF Core is a lightweight, cross-platform version of EF, useful for ASP .NET Core web app developers. This article isn’t going to try and convince you of the benefits of using an ORM. If you’re reading this article, hopefully you’ll already recognize the value of using an ORM for your web app.

Instead, we’ll be focusing on EF Core Migrations for taking control of your database. By using migrations, you’ll be able to add and manipulate database objects, define relationships between entities and help developers and server environments stay in sync with specific versions of your database schema.

EFCore-diagrams

Continue reading

NetLearner – ASP .NET Core Internet Learning Helper

By Shahed C on November 11, 2018

This is the sixth of a new series of posts on ASP .NET Core. This week, we’ll be looking  at NetLearner, a new ASP.NET Core Web app to organize online learning resources.

ASPNETCoreLogo-300x267

NetLearner: What is it?

NetLearner is an ASP .NET Core web app to allow any user to consolidate multiple learning resources all under one umbrella.

NetLearner-logo

Some Background: As I’ve been doing a lot of R&D on ASP .NET Core, I found myself keeping track of blog posts, podcasts, YouTube videos, Twitch streams, Pluralsight tutorials, ebooks across Amazon, Safari Books Online, and so much more. I’ve been using Notepad, OneNote, browser bookmarks, Twitter lists, emails to myself, Google/Word docs and so much more just to keep track of URLs, notes and progress. I’m building this new app for myself to organize my learning plans, but also open-sourcing it and deploying it to allow others to use it too.

Web NetLearner on GitHub: https://github.com/shahedc/NetLearner

The name implies 2 things: the app’s source code will be a real-world example for people learning .NET (specifically ASP .NET Core 2.1 and beyond), and the tool itself will help people learn any topic from various resources across the Internet.

What can you expect in 2019?

  1. Use the web app’s source code to learn all about ASP .NET Core 2.1+ and beyond.
  2. Add links to various learning resources: books, articles, blogs, conference sessions, podcasts, online workshops, videos and livestreams.
  3. View embedded content where appropriate, e.g. videos
  4. See contents of RSS feed where appropriate, e.g. blogs with RSS
  5. Discover what others have added to their NetLearner lists, via suggestions of what’s popular.
  6. Follow content creators with links to their social media accounts.
  7. Deploy your own instance instantly to your own Azure account.
  8. Build lists to learn anything and share with others.

Stay tuned for more information!

Your Web App Secrets in ASP .NET Core

By Shahed C on November 4, 2018

This is the fifth of a new series of posts on ASP .NET Core. This week, we’ll be looking  at app secrets for ASP .NET Core projects, for use in development environments.

ASPNETCoreLogo-300x267

Protecting Application Secrets During Development

Most web apps need to store some configuration information that can be accessed by the application during runtime. This may include database connection strings and API keys, which are not user-specific confidential values, but are still sensitive pieces of information that need to be protected.

Once in a while, a developer may accidentally commit such sensitive information to public repositories such as Github. Quoting this blog post from the Azure website, “Keep in mind that removing a published secret does not address the risk of exposure. The secret may have been compromised, with or without your knowledge and is still exposed in Git History. For these reasons, the secret must be rotated and/or revoked immediately to avoid security risks.”

This blog post intends to prevent you from ever making that mistake in the first place. You may download the following sample project to follow along.

Web AppSecretDemo: https://github.com/shahedc/AppSecretDemo

Continue reading

Protocols in ASP .NET Core: HTTPS and HTTP/2

By Shahed C on October 28, 2018

This is the fourth of a new series of posts on ASP .NET Core. This week, we’ll be looking at the use of HTTPS in ASP .NET Core projects (using HTTP/1.1 today) and also HTTP/2 support for future ASP .NET Core projects.

ASPNETCoreLogo-300x267

HTTPS and SSL

If you’re reading this blog post, you’re probably familiar with HTTPS and the little lock symbol that appears on websites that have a valid SSL certificate. It’s actually TLS these days, and you can read more about SSL, TLS and HTTPS here:

Recently, the popular Google Chrome browser received an update that automatically displays a “Not Secure” message for any website that doesn’t use SSL. To address this, I updated this blog site to ensure that all embedded content use HTTPS when the site is loaded with HTTPS. I took it one step further and always enabled SSL so that site visitors going to WakeUpAndCode.com (with just HTTP) will be redirected to https://WakeUpAndCode.com.

This site is a WordPress site, so I was able to make the last change by installing a free plugin called Really Simple SSL.

If you’re not convinced you need SSL, just read this thread on Twitter:

EDIT: If you need another nudge in the right direction, here’s a gentle reminder from Troy Hunt, a well-known influential computer security expert in the Microsoft world. Troy highlights an anti-HTTPS debate that illustrates why it doesn’t make sense to be against it.

HTTPS in ASP .NET Core

For years, it has been too easy for ASP .NET developers to build Web Apps and Web APIs without any HTTPS during development. It wasn’t uncommon for web application developers to make excuses about not running their web apps with SSL on their local development environments, even if the application needed to be deployed to production with SSL (which production app doesn’t?).

Continue reading

Pages in ASP .NET Core: Razor, Blazor and MVC Views

By Shahed C on October 21, 2018

This is the third of a new series of posts on ASP .NET Core. This week, we’ll be looking at various types of Pages you may encounter in an ASP .NET Core web app:

  1. Razor Pages (new as of v2.0)
  2. the experimental Blazor (C# in the browser!)
  3. the more familiar MVC Views (aka Razor Views)

If you already know how to create each type of project, feel free to jump past section 3B below.

ASPNETCoreLogo-300x267

Before you begin

Before you begin, make sure you download an IDE or code editor to open and run the code samples. My recommendations are below:

A. Visual Studio Code: https://code.visualstudio.com

B. Visual Studio 2017 (v15.8 or later): https://visualstudio.microsoft.com/vs/

vs-logos

To get the latest SDK, download .NET Core v2.1 or higher:

Web .NET Core Download: https://www.microsoft.com/net/download

To use Blazor in Visual Studio 2017, you must install the ASP .NET Core Blazor Language Services extension from the Visual Studio Marketplace:

Web Blazor extension: https://marketplace.visualstudio.com/items?itemName=aspnet.blazor

The instructions below will cover both Command Line Interface (CLI) commands and IDE/editor steps to create, build and run the code samples.

Web Sample code: https://github.com/shahedc/PagesDemo

Continue reading