ASP.NET Core

Working with Sass in an ASP.NET Core application

calendar_today 20 April 2023 12:40

CSS ASP.NET Core .NET 6 .NET 7 Sass

Sass (Syntactically Awesome Style Sheets) is a is a scripting language that is used to generate cascading style sheets (CSS files). Its syntax is very similar to CSS itself, but it supports the use of variables, nesting, mixins and selector inheritance, none of which are available in CSS itself. However, these features help you to organise and maintain your web application's styles. In this article, I look at the steps required to incorporate and configure Sass in your ASP.NET Core project in both Visual Studio, and VS Code.

Why doesn't my ASP.NET Core 7 web app launch on HTTPS?

calendar_today 20 March 2023 13:37

ASP.NET Core Razor Pages .NET 6 .NET 7

Up until .NET 7, when you use the dotnet run command to run your ASP.NET Core Razor Pages (or MVC) app, the built-in Ketstrel web server would listen on two URLs, one with a http protocol and another that uses the https protocol. This behaviour is documented in many places (including my book) so it might come as a surprise when you run your new .NET 7 app from the command line and it is only available on an http binding. Something changed in .NET 7. What is it and how do you test your .NET 7 web app under https?

Executing async operations onchange in Blazor

calendar_today 10 January 2023 07:35

ASP.NET Core Blazor .NET 7

Blazor's two-way databinding model is extremely powerful, but sometimes it can get in the way of what you want to do. For example, you might want to execute an asynchronous operation such as remote validation when a value changes in a textbox. Perhaps you want to check instantaneously that the value - a username maybe - doesn't already exist in a database before you accept a new registration. You cannot add an onchange event handler if you already have a value bound to the element, so what can you do? In this article, I look at solutions for both HTML elements and EditForm input validation components up to an including .NET 7, and a new feature released in .NET 7.0.1.

Exploring generating PDF files from HTML in ASP.NET Core

calendar_today 30 November 2022 13:45

iTextSharp HTML5 ASP.NET Core Razor Pages Bootstrap .NET 6

Back in 2008, I wrote a series of articles about using iTextSharp to generate PDF files in an ASP.NET application. I still use iTextSharp in a large MVC 5 application that I'm in the process of migrating to ASP.NET Core. The version I use is very old (4.1.6), and the API is very low level so it takes quite a while to write the code required to generate even a moderately complex PDF. Ideally I need a replacement for the new application that can generate PDF files purely from HTML, which is an API I'm much more comfortable with. This ancient version of iTextSharp doesn't support HTML as a source of content. In this article, I consider some alternatives.

A reusable generic autocomplete component for Blazor

calendar_today 17 November 2022 13:14

ASP.NET Core Blazor

In my last article, I looked at building a simple autocomplete component within a Blazor WebAssembly application that fetches data dynamically from a database via an API depending on what the user enters into an input. It works nicely but it has not been designed to be reusable. In this article, I look at the steps required to convert the component so that it can be plugged in anywhere within an application and work with any kind of data.

Simple Autocomplete for Blazor

calendar_today 07 November 2022 13:35

ASP.NET Core Blazor

One of the things I really like about Blazor is how often it is easy to implement features in your application that, if needed in a server-side application, would have you testing your JavaScript-fu or reaching for a third party component. One example is an autocomplete component that fetches live data from a database that matches that which a user enters into a form control and changes as the user types. In this article, I'll show how to build such a component for a Blazor WebAssembly app and style it like a dropdown.

Resize images before uploading in Blazor Web Assembly

calendar_today 31 October 2022 14:02

ASP.NET Core Blazor

So, you allow users to upload images to the server from your Blazor WASM app, but you want to constrain the actual dimensions of the image for some reason. Rather than ask the user to edit the image prior to uploading, you decide to to take care of applying this requirement within the application. And you further decide to do any resizing in the browser prior to uploading so that the resulting upload is smaller and you don't have to waste server resources on the procedure. In this article, I take a look at how to do that, and how to get the dimensions of an image file.

Incrementally Migrating an ASP.NET Framework application to Razor Pages

calendar_today 01 September 2022 07:08

ASP.NET MVC ASP.NET Web Forms ASP.NET Core Razor Pages .NET 6

Do you have a huge .NET framework application (Web forms, MVC) that relies on authentication and/or System.Web types that you would ideally like to migrate to .NET Core, but just don't have the bandwidth to put everything on hold while you rewrite the entire application on a new framework? If so, you might be interested in an exciting new project from Microsoft - SystemWebAdapters for ASP.NET Core - that enables you to incrementally migrate your old application, endpoint by endpoint.

Strongly Typed Middleware in ASP.NET Core

calendar_today 24 August 2022 12:30

ASP.NET Core Razor Pages .NET 6

Most ASP.NET Core developers are familiar with the traditional way to author middleware classes which is based on conventions. The vast majority of examples out there feature the convention-based approach. But there is also a strongly typed approach available which is based on implementing the IMiddleware interface. This seems to be one of ASP.NET Core's best kept secrets, so I thought I'd pull the curtains back and let some light shine on it.

Using Minimal APIs in ASP.NET Core Razor Pages

calendar_today 14 December 2021 13:33

ASP.NET Core Razor Pages .NET 6

If you are using ASP.NET Core Razor Pages to develop your web application, you have already decided that the majority of your HTML will be generated on the server. Nevertheless, chances are that you will want to introduce some client side operations into the application to improve its user friendliness in places. If those operations involve data, you will probably want to work with JSON. From .NET 6, you can use a simplified minimal request handler API that works with JSON by default.

Razor Pages Startup in .NET 6

calendar_today 06 October 2021 13:05

ASP.NET Core Razor Pages .NET 6

When you create a new web app using .NET 6 (from the new RC1 templates), you might notice something is missing. There is no Startup class. What happened to it? And how do you configure your new .NET 6 web app?

I am writing a book about Razor Pages

calendar_today 26 July 2021 18:13

ASP.NET Core Razor Pages .NET 6

Just over three years go, when Razor Pages was first launched, I had a number of questions from people asking whether I was going to write a book about the Razor Pages framework. I guess they asked me because Razor Pages appeared to be a natural successor to the old ASP.NET Web Pages framework, and I had written a book about that. Also, I was regularly blogging at the time about all the good things you could do with Razor Pages. The answer then was No, primarily because I was working on my own tutorial/documentation site for Razor Pages - learnrazorpages.com.

CSS Isolation In Razor Pages

calendar_today 19 July 2021 10:54

ASP.NET Core Razor Pages .NET 6

CSS isolation was introduced in .NET 5 for Blazor components. Now it's coming to Razor Pages (and MVC views) in .NET 6, due to be released in November this year. Here's a quick look at how CSS isolation works in Razor Pages and the kind of problem that it's designed to solve.

Implementing a Custom TypeConverter In Razor Pages

calendar_today 24 November 2020 18:34

ASP.NET Core Razor Pages

In my most recent article, I showed how to create a custom model binder to bind an ISO 8601 string representation of a week of the year to a DateTime type in a Razor Pages application. The custom model binder leant heavily on the existing infrastructure that binds strings to simple types. Custom model binders are the correct solution if you want to bind to simple types, but if you want to bind to a complex type, the recommendation is to implement a TypeConverter according to the offical docs. But the docs don't provide an example that shows how to do that in the context of model binding. So here's one.

Implementing a Custom Model Binder In Razor Pages

calendar_today 10 November 2020 15:28

ASP.NET Core Razor Pages

In Razor Pages, model binding is the process that maps data from an HTTP request to simple PageModel properties or handler parameters. Incoming data can be included in a request as posted form values, query string values or route data. The default collection of model binders cover every simple .NET data type.. But sometimes they are not enough, and you need to add your own implementation.

Working with Dates And Times in Razor Pages Forms

calendar_today 02 November 2020 17:17

ASP.NET Core Razor Pages

When working with dates and times in a Razor Pages form, you need to render a suitable control based in the task requirement. Prior to HTML5, developers largely depended on third party date picker libraries. Now, a variety of native browser options exist, although they enjoy varied support across modern browsers. These include options for managing the date and time, just the date or time, and for working with the month or week of the year.

Display Images in Bootstrap Carousel using Razor Pages and Entity Framework

calendar_today 19 June 2020 15:37

ASP.NET Core Razor Pages Bootstrap

This short article shows how to display images stored in a database in a Razor Pages application using the Bootstrap Carousel and Entity Framework Core.

Razor Pages And Bootstrap - Lazy Loading Tabs

calendar_today 10 June 2020 12:34

ASP.NET Core Razor Pages Bootstrap

Tabbed interfaces are a great way for managing the presentation of large amounts of information into separate panels, where each panel's data makes sense on its own, and only one panel is viewable at a time. The tabs in a browser are a great example of this. From a Razor Pages developer's point of view, tabs are particularly useful for controlling the display of complex data in Line Of Business applications.

Razor Pages And Bootstrap - Modal Master Details

calendar_today 28 May 2020 16:09

ASP.NET Core Razor Pages Bootstrap

This is the first in a series of posts exploring how to use some of the components provided by Bootstrap within a database-driven Razor Pages web application. In this article, I look at using the Bootstrap Modal in a Master/Details scenario, to display the details of the selected record in a master list.

Razor Pages Localisation - SEO-friendly URLs

calendar_today 07 January 2020 07:37

ASP.NET Core Razor Pages Localization

This is the fourth article in a series that explores various aspects of localisation in ASP.NET Core Razor Pages applications. This article concentrates on the SEO aspects of localisation as they pertain to URL management, and how to utilise the RouteDataRequestCultureProvider to help you manage that.

Localising Data Annotation Attributes in Razor Pages

calendar_today 17 December 2019 07:33

ASP.NET Core Razor Pages Localization

This is the third article in a series that explores various aspects of localisation in ASP.NET Core Razor Pages applications. The first article looked at how to work with cultures, and the second covered the basics of using resource files for static content translations. In this article, I explain how to provide localised resources for form labels and validation error messages for PageModel properties that have Data Annotation attributes applied to them.

Using Resource Files In Razor Pages Localisation

calendar_today 10 December 2019 07:50

ASP.NET Core Razor Pages Localization

This is the second in a series of articles that cover localisation in ASP.NET Core Razor Pages applications. In the previous article, I looked at the basic configuration required to work with cultures which are the basic building block of localisation. I showed how to specify the cultures that the application supports, how to set the culture for the current request, and how some items, such as calendars are translated depending on the current culture. This article builds on the application which was introduced in the the last article and explores how to configure and use resources to store translated versions of static content.

Localisation in ASP.NET Core Razor Pages - Cultures

calendar_today 03 December 2019 07:50

ASP.NET Core Razor Pages Localization

This is the first in a series of articles that explores localisation in ASP.NET Core Razor Pages applications. This article will look at the configuration required to prepare a site for content localisation, in other words, to globalise the site. Future articles will cover the creation of localised content and how to present it.

What Happened To @Helpers In ASP.NET Core?

calendar_today 21 November 2019 13:11

ASP.NET Web Pages Razor ASP.NET Core Razor Pages

When you port your Razor-based application to ASP.NET Core, whether its an MVC application or a Web Pages application, you might notice that adding a @functions block to your .cshtml file works as expected, but any attempt to add a @helpers block doesn't work at all.

Improved Remote Validation in Razor Pages

calendar_today 13 November 2019 07:51

ASP.NET Core Razor Pages

Remote Validation is a technique that uses client side script to validate user input on the server without posting the entire form. Remote validation has always been possible in Razor Pages using either the RemoteAttribute, which requires an MVC controller to work, or by writing custom client-side script. One almost completely overlooked feature that was included in ASP.NET Core 3.0 was the introduction of a Razor Pages-specific validation attribute that removes this reliance on MVC controllers or custom code for remote validation.

Managing Authentication Token Expiry In WebAssembly-based Blazor

calendar_today 05 November 2019 13:50

ASP.NET Core Blazor

The Blazor WebAssembly project template doesn't feature an option to include authentication. If you want to add authentication to a WebAssembly-based Blazor application, you need to do it yourself. This article shows how to add application-wide authentication management and then to use built-in Razor components to protect the FetchData page in the standard template from unauthorised users.

Uploading Files In Blazor

calendar_today 17 October 2019 07:47

ASP.NET Core Blazor

A few weeks ago, Steve Sanderson blogged about publishing a package for a prototype Blazor file input component, designed to make working with user-supplied files in Blazor applications a lot easier. Steve has provided some very clear examples demonstrating how to use the component in a number of scenarios. Missing, though, is an example showing how to make an HTTP request to upload a file to some back-end server from a Blazor WebAssembly application.

Working With Query Strings In Blazor

calendar_today 11 October 2019 12:44

ASP.NET Core Blazor

When passing data in a URL within a Blazor application, most of the time you will define route templates that incorporate parameter placeholders, passing values as URL segments. You might also find that you need to be able to work with query string values, so how do you do that in a Blazor application?

Optional Parameters in Razor Pages Routing

calendar_today 21 August 2019 20:11

ASP.NET Core Razor Pages

Razor Pages routing is based on attribute routing and is very powerful. Parameters provide a way of passing arbitrary data to a page via the URL. Optional parameters allow URLs to matched to routes even if no parameter value is passed. Things can get a bit complicated if you want to permit multiple optional parameters.

Using Razor Components In A Razor Page

calendar_today 05 August 2019 12:40

ASP.NET Core Razor Pages Blazor

In my last article, I looked at some of the new things that ASP.NET Core 3.0 will introduce to Razor Pages developers. One of the features that I touched on was Razor Components. In this article, I take a more detailed look at what they are and how they can be used.

What's New In .NET Core 3.0 For Razor Pages

calendar_today 24 July 2019 19:44

ASP.NET Core Razor Pages Blazor

Later this year, .NET Core 3.0 will be released. The main features include WPF and Windows Forms support (albeit only on the Windows operating system) and server-side Blazor. Razor Pages applications will also see some changes. I cover some of these as part of a guide to upgrading an application from 2.2 to 3.0. Then I have a quick look at some of the other new features. Note that the information in this article is based on Preview 6, and is subject to change.

AJAX Posts In Razor Pages And HTTP 400 Errors

calendar_today 15 July 2019 12:41

ASP.NET Core Razor Pages

Every other day or so it seems, a new question is posted to one of the community forums that cover ASP.NET Core Razor Pages asking why an AJAX post doesn't appear to work, or results in an HTTP 400 error. This article explains the most common cause, and offers guidance on how to solve it.

Simple Authentication In Razor Pages Without A Database

calendar_today 08 May 2019 07:26

ASP.NET Core Razor Pages ASP.NET Identity

Sometimes, using the full ASP.NET Core Identity framework is overkill for small, one-user applications that require some form of authentication. I'm thinking about blog applications, or web-based utilities that have admin areas that only you should be allowed to reach. All you really want to do is authenticate against a user name and password stored in a config file or similar. You really don't need the ceremony of a database, EF Core, ApplicationDbContexts, SignInManagers, UserManagers etc. This article provides a step-by-step guide to implementing simple authentication using just cookies, while storing credentials securely without a database.

Using Parameter Transformers To Modify Route And Parameter Values In Razor Pages

calendar_today 29 April 2019 08:45

ASP.NET Core Razor Pages

Available from ASP.NET Core 2.2, parameter transformers enable the centralisation of logic for modifying the value of routes and route parameters in URLs generated by the anchor tag helper or the Url helper.

Creating Custom Constraints For Razor Pages Routes

calendar_today 01 April 2019 09:16

ASP.NET Core Razor Pages

Razor Page already includes a wide range of constraints that can be used to help disambiguate routes. It is also possible for you to create your own custom constraint and then register that with the routing system.

Rendering A Partial To A String In Razor Pages

calendar_today 19 March 2019 08:22

ASP.NET Core Razor Pages

Partial Views or Pages are primarily used as a means of including reusable snippets of HTML within one or more Razor Pages. This walkthrough illustrates how to take advantage of the power of the Razor templating system used by partial pages to generate HTML for other purposes, such as the body of a mail message.

Global Error Handling And Logging With NLog In Razor Pages

calendar_today 12 February 2019 08:26

ASP.NET Core Razor Pages

Exceptions in .NET represent an error condition in an executing program. Error conditions can come about as a result of a large number of causes, each represented by its own exception type. Most exceptions arise from logical errors in code, such as an attempt to work with an object that has not been instantiated (NullRefrenceException), or to divide by zero (DivideByZeroException). Other types of exceptions result from technical issues, which may or may not be temporary. Examples of such issues might include a database or mail server being unavailable, or insufficient file system permissions.

Including Static Resources In Razor Class Libraries In ASP.NET Core

calendar_today 17 October 2018 13:32

ASP.NET Core Razor Pages

Razor Class libraries (RCLs) were introduced in ASP.NET Core 2.1 as a way to package and distribute UI components to be referenced and consumed within a host application. You can see them as a fully functioning part of a web application packaged as a class libray. The templated management pages for ASP.NET Identity were included as a Razor Class Library in the project template in 2.1. The Identity UI RCL includes the Razor pages, Filters, a stub EmailService class that Identity uses, and local versions of both Bootstrap 3 and 4.

Adding Sorting To Paging In ASP.NET Core Razor Pages

calendar_today 10 October 2018 08:35

ASP.NET Core Razor Pages

This article builds on the simple paging functionality that was added to a Razor Pages application in my last article by showing how to add sorting functionality so that the user can determine the order in which results are displayed.

Simple Paging In ASP.NET Core Razor Pages

calendar_today 03 October 2018 07:49

ASP.NET Core Razor Pages

This article attempts to demonstrate how to implement simple paging functionality in a Razor Pages application. I will explain the basics behind paging, and then use BootStrap 4 to render a variety of paging links, without resorting to Nuget packages for link generation.

Customising Routing Conventions In Razor Pages

calendar_today 26 September 2018 07:39

ASP.NET Core Razor Pages

At its heart, the Razor Pages routing story is a simple one. It uses a convention of mapping URLs to files on disk. There are ways to customise how pages are found on an individual basis, but what if you want to change the default convention in its entirety? There is also a way to do that. And it's quite simple, as this article will demonstrate, using two real-world examples.

Using Unobtrusive Ajax In Razor Pages

calendar_today 17 September 2018 08:17

AJAX ASP.NET Core Razor Pages

There are a few demonstrations showing how to use the jQuery Unobtrusive AJAX library in ASP.NET Core, but existing examples tend to feature MVC applications. This article looks at how to use Unobtrusive AJAX in a Razor Pages setting, where it will help to remove a lot of the boilerplate associated with making AJAX requests.

Partials and AJAX In Razor Pages

calendar_today 07 September 2018 15:57

AJAX ASP.NET Core Razor Pages

Updating portions of a page using AJAX and partial views is a routine task in ASP.NET MVC applications. The experience is little different in ASP.NET Core Razor Pages - not much, but enough to stump some people. Here is some advice on accomplishing this task, and a preview of some additional help coming in the near future.

Areas In Razor Pages

calendar_today 03 September 2018 08:01

ASP.NET Core Razor Pages

Support for Areas was added to Razor Pages with the release of ASP.NET Core 2.1. They have long been used in MVC applications as a way to separate logical chunks of large applications into semi-independent modules to facilitate team working etc. Here, I explore how to use areas in a Razor Pages application.

Accessing The Model From Filters In Razor Pages

calendar_today 29 August 2018 08:23

ASP.NET Core Razor Pages

Support for filters was added to Razor Pages with the release of ASP.NET Core 2.1. Filters, for those unfamiliar with them, are components that enable the injection of processing at certain points within the Razor Page lifecycle. They differ from Middleware in that they provide access to the HttpContext. Razor Pages offers a number of different filter options. One of the things that you might want to do in a filter is to obtain data from an external resource (database, web service etc) and then use it in the PageModel or ViewData. Here, I take a look at how you can access the model or ViewData dictionary depending on the type of filter implementation that you choose.

Query Types in Entity Framework Core

calendar_today 15 August 2018 13:46

Entity Framework ASP.NET Core

Query Types, introduced in Entity Framework Core 2.1 enable you to return non-entity types that map to tables or views and can serve as the return type from FromSql method calls.

Razor Pages, TypeScript and Knockout

calendar_today 16 July 2018 07:54

Javascript ASP.NET Core Razor Pages TypeScript

In this article, I look at the steps required to get TypeScript up and running in the context of a Razor Pages application. I discuss why you might want to do this, and I use Knockout for the purposes of demonstration. By the end of the article, I will have configured and used TypeScript to replicate part of the final code for the Single Page Application tutorial from learn.knockout.com.

Cascading Dropdowns With Blazor

calendar_today 24 May 2018 20:51

ASP.NET Core Blazor

Blazor is an experimental framework introduced by Steve Sanderson of Knockout.js fame (among other things) on the ASP.NET team. The premise of the framework is simple, but potentially game-changing for ASP.NET developers: it enables you to write your client side code in C#. What this means is that rather than having to chase after the latest Javascript-based hotness - Aurelia, React, Angular etc, only to find that they are dependent on learning a whole new load of frameworks, or that they are no longer flavour of the week, you just use the .NET skills that you already have to move your processing to the browser.

Working With JSON in Razor Pages

calendar_today 21 May 2018 13:49

ASP.NET Core Razor Pages

UI generation and processing within web applications is moving increasingly to the client. Data processing and storage is still undertaken on the server, with JSON being the preferred format for exchanging data between the server and the client. There are a number of ways in which you can generate JSON when working with Razor Pages. This article explores some of them.

Extending the Command Timeout in Entity Framework Core Migrations

calendar_today 26 March 2018 08:50

Entity Framework ASP.NET Core

Most migrations that you execute when working with Entity Framework Core are likely to be straightforward - resulting in nothing more than an adjustment to the database schema. Sometimes, however, you might also want to include a task that requires longer than the default command timeout value (30 seconds in SQL Server) such as importing a lot of data.

Publishing Razor Pages Applications - Gotchas

calendar_today 22 March 2018 08:15

ASP.NET Core Razor Pages

I have just completed an article covering publishing a Razor Pages application to IIS on my Razor Pages dedicated site: learnrazorpages.com. While writing it (and publishing revised versions of the site) I uncovered a few stumbling blocks that might catch others out. So I thought they were worth highlighting here in their own post.

ViewModels and AutoMapper in Razor Pages

calendar_today 14 February 2018 08:13

ASP.NET Core Razor Pages

The Razor Pages PageModel class is part controller, part ViewModel. In this article, I take a look at the ViewModel part of the role that the PageModel plays, and how tools like AutoMapper can be used to reduce the amount of code you need to write when assigning values between your entity model and your ViewModel.

I'm Not Writing A Book On Razor Pages

calendar_today 19 January 2018 08:47

ASP.NET Core Razor Pages

That's right - despite a number of questions, I am not writing a book on Razor Pages, the new page-based web development framework released as part of ASP.NET Core 2.0. But I have launched a web site for people who want to learn how to use ASP.NET Core Razor Pages.

Customising Identity in Razor Pages

calendar_today 22 September 2017 14:16

ASP.NET Core Razor Pages ASP.NET Identity

The code for managing authentication in a Razor Pages application that is provided by the standard project template is a good starting point. However, chances are that you want to customise it to fit your own application needs. This article looks at the most common customisation requirements.

Introduction to Identity in Razor Pages

calendar_today 08 September 2017 08:09

ASP.NET Core Razor Pages ASP.NET Identity

Razor Pages uses ASP.NET Identity as its default membership and authentication system. This article is the first in a series that explores the various parts of ASP.NET Identity as it relates to Razor Pages, and starts with an overview of the files generated as part of the project templates.

Sending Email in Razor Pages

calendar_today 20 July 2017 07:24

ASP.NET Core Razor Pages

The Razor Pages framework is not the only thing to be introduced as part of .NET Core 2.0. A lot more of the existing full framework class libraries are also being ported across to .NET Core including System.Net.Mail. That means there is no longer any need to rely on third party libraries or services for email functionality in your .NET Core applications. So I thought I'd take the opportunity to illustrate sending email in a Razor Pages application.

Routing in Razor Pages

calendar_today 11 July 2017 13:28

ASP.NET Core Razor Pages

One of the top level design considerations for the developers of a server-side web application framework is how to match URLs to resources on the server so that the correct one processes the request. The most straightforward approach is to map URLs to physical files on disk, and this is the approach that has been implemented by the ASP.NET team for the Razor Pages framework.

Razor Pages - The Elevator Pitch

calendar_today 25 May 2017 08:29

ASP.NET MVC ASP.NET Core Razor Pages

In the last ASP.NET Community Standup, Jon Galloway gave my introductory Razor Pages article a shout out (thank you, Jon). During the discussion that ensued, Scott Hanselman asked for the "elevator pitch" for Razor Pages. Well, here's mine.

Razor Pages - Understanding Handler Methods

calendar_today 22 May 2017 20:16

ASP.NET Core Razor Pages

Handler methods is a particularly nice feature introduced with the new ASP.NET Razor Pages framework . This feature enables you to determine what the user was doing when they requested the page, and to execute logic accordingly without having to resort to a bunch of conditional code.

Razor Pages - Getting Started With The Preview

calendar_today 15 May 2017 20:52

Razor ASP.NET Core Razor Pages

Current users of ASP.NET Web Pages have been eagerly awaiting news on what ASP.NET Core holds for them (if my inbox is anything to go by). The roadmap suggested that a new version of Web Pages would be forthcoming after the initial release of .NET Core, but that item was subsequently removed. Instead, a new cross platform page-centric web development model called Razor Pages has been made available in preview form. Here, I show you how to get started with it and explore its similarities with Web Pages. In future articles, I will take a closer look at the wide range of differences.

Free SSL Certificates On IIS With LetsEncrypt

calendar_today 02 February 2017 07:44

ASP.NET MVC ASP.NET Web Forms ASP.NET Core

If you have forms on your site that take a user's personal details, you should protect the page by running it under HTTPS. That way, any data that's posted from the form (email address, credit card number etc) is encrypted and hidden from prying eyes. It's not just e-commerce sites that should be protected. Intranets and other line of business apps that require authentication, blogs with comment forms that ask for email addresses and so on. The main barrier to this in the past has been the cost of the digital certificate (SSL Certificate) that asserts that you are who you say you are. LetsEncrypt is a free, automated, and open Certificate Authority that removes this barrier.

Entity Framework Core DbContext Updated

calendar_today 28 October 2016 08:50

Entity Framework ASP.NET Core

Redesigning a framework from the ground up provides an opportunity to implement an improved API. The team working on Entity Framework Core have certainly grabbed that opportunity in respect of the DbContext class, which sees a bunch of new data manipulation methods not available in Entity Framework 6 or earlier.

Entity Framework Core TrackGraph For Disconnected Data

calendar_today 11 October 2016 21:40

Entity Framework ASP.NET Core

Entity Framework Core is the new lightweight version of Entity Framework designed to work with .NET Core applications. Just like ASP.NET Core, it has been rewritten from the ground up, and includes some new ways of doing things. One of those is the introduction of the TrackGraph method for handling complex data in disconnected scenarios such as MVC or Web API applications.

Server.MapPath Equivalent in ASP.NET Core

calendar_today 02 September 2016 14:55

ASP.NET Core

Web Developers who use Microsoft technologies have always relied on the Server.MapPath method to resolve file paths in classic ASP and ASP.NET Web Forms and MVC versions up to and including 5. This method has not been included in ASP.NET Core, so what do you use instead?

Loading ASP.NET Core MVC Views From A Database Or Other Location

calendar_today 21 July 2016 08:56

ASP.NET MVC ASP.NET Core

For the vast majority of ASP.NET Core MVC applications, the conventional method of locating and loading views from the file system does the job nicely. But you can also load views from other sources including a database. This is useful in scenarios where you want to give users the option to craft or modify Razor files but don't want to give them access to the file system. This article looks at the work required to create a component to obtain views from other sources, using the database as a working example.

ASP.NET Web Pages vNext or Razor Pages

calendar_today 15 July 2016 14:09

ASP.NET MVC ASP.NET Web Pages ASP.NET Core Razor Pages

Now that the RTM of ASP.NET Core has shipped, the ASP.NET team are looking at the features that were left behind including SignalR and Web Pages. The ASP.NET Core road map always had those items scheduled for inclusion in the first major release after RTM, which will be ASP.NET Core 1.1. Recently, the ASP.NET Team provided an update on GitHub on the goals driving the next version of Web Pages which provides an interesting insight into the potential features of the framework.

Encryption and Decryption in ASP.NET Core

calendar_today 01 March 2016 13:15

ASP.NET MVC ASP.NET Core

The ASP.NET Core framework provides a new API for protecting data, including mechanisms for encryption and decryption. This article takes a quick look at how they can be used.

View Components in ASP.NET Core MVC

calendar_today 12 February 2016 08:45

ASP.NET MVC ASP.NET 5 ASP.NET Core

The ASP.NET Core MVC framework (previously known as MVC 6) includes a new feature called View Components. Here, I take a look at them, the kind of problems they are designed to solve and how to use them.

Configuring SQL Server For Session State In ASP.NET Core 1.0 MVC

calendar_today 11 January 2016 13:14

ASP.NET MVC ASP.NET 5 ASP.NET Core

This article looks at the steps required to enable SQL Server as a backing store for Session State in an ASP.NET Core 1.0 MVC application. It builds on my previous article which introduces how to configure and use session state in ASP.NET 5.

Uploading files with ASP.NET Core 1.0 MVC

calendar_today 27 October 2015 13:58

ASP.NET MVC ASP.NET 5 ASP.NET Core

Handling file uploads has changed quite a bit in ASP.NET Core. This article looks at the new objects that have been introduced to replace the old System.Web based approach from previous versions of ASP.NET. **Updated to RTM**

ASP.NET Core: Dependency Injection and Services in MVC

calendar_today 24 September 2015 08:05

ASP.NET MVC ASP.NET 5 ASP.NET Core

This is the fourth in a series of articles that explores ASP.NET Core by reconstructing the Visual Studio 2015 Web Application template from an Empty template. This article looks at the role of services and the new ASP.NET Core dependency injection system. The series of articles has been developed using Visual Studio RTM and ASP.NET Core Beta 6. It will be kept updated along with newer releases.

Sessions in ASP.NET Core

calendar_today 07 April 2015 13:39

ASP.NET MVC ASP.NET 5 ASP.NET Core

ASP.NET Core is being designed so that your application is only dependent on features that it actually needs. This is achieved in large part by creating a composable framework, where the developer opts in to non-essential features - a number of which are baked in to traditional versions of ASP.NET. One of the features that this applies to is Session State. This article looks at how to obtain and use session state in ASP.NET Core applications.