Using Razor Pages to simplify basic actions in ASP.NET Core 2.0 preview

Using Razor Pages to simplify basic actions in ASP.NET Core 2.0 preview

ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core 2.0 hosting. One of the brand new features added to ASP.NET Core in version 2.0 preview 1 is Razor Pages. This harks back to the (terribly named) ASP.NET Web Pages framework, which was a simpler, page-based, alternative framework to MVC. It was a completely different stack, and was sort of .NET's answer to PHP. I know, that might make you shudder, but I've actually had a fair amount of success with it. It allowed our designers who had HTML knowledge but no C# to be productive, without having to deal with full MVC. Web developers might turn their nose up at that, but there's really no reason for a designer to go there, and would you want them to? A developer could just jump on for any dynamic bits of code that were beyond the designer, but otherwise you could leave them to it. This post dips a toe into the justification of Razor Pages...
Read More
Configuring ASP.NET Core Application Settings

Configuring ASP.NET Core Application Settings

ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core 2.0 hosting. With all of the controversy around project configurations within .NET Core, one thing that has managed to be consistently JSON-based has been the use of application settings configuration files in this new world. While JSON does read incredibly easily, it can very quickly become muddled if you are storing large, complex objects consisting of nested objects and arrays, each with multiple properties of different types, and so on. Thankfully, you have options. And I don't mean options like going to use XML; I mean that there's a specific framework designed to tackle issues like these and make working with these potentially cumbersome configurations much more manageable. Enter the Options Framework The Options framework is a very basic framework that is specifically designed to handle accessing and configuring POCO settings within .NET Core, and it simply couldn't be easier to work with. Now let's say that you have a configuration file for your application that looks...
Read More
What is Difference between ASP.NET MVC 5 and ASP.NET MVC Core 1.0

What is Difference between ASP.NET MVC 5 and ASP.NET MVC Core 1.0

ReviewCoreASP.NET | Best and cheap ASP.NET MVC Core 1.0 hosting. The best way to learn new technologies is via comparing with the old and find out what has changed. In this post, find out the difference between ASP.NET MVC 5 and ASP.NET MVC Core 1.0 aka ASP.NET MVC 6. The difference list is quite long as ASP.NET Core 1.0 is re-written. The basic of MVC still remains the same and we can say that from coding perspective there aren’t many changes but there are framework level changes, project structure changes, hosting and deployment changes and many more. So let’s dive in.  ...
Read More
How Getting started with ASP.NET Core 2.0 Preview

How Getting started with ASP.NET Core 2.0 Preview

ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core 2.0 hosting. In this post I want to focus in on a few changes to the basic structure of ASP.NET Core 2.0 applications which simplify the code needed to get started. Before looking at those elements, I felt it would be worth sharing the steps I took to get started with ASP.NET Core 2.0 Preview 1 on my development machine. Getting started with ASP.NET Core 2.0 preview 1 The first step was to get the preview SDK for .NET Core 2.0 which can be safely installed alongside any prior 1.x SDK versions. The announcement post provides a link to download the SDK. The next step was to install the SDK. Nice and easy! Initially I tried creating a project in the existing Visual Studio 2017 IDE. I did so by starting with an ASP.NET Core 1.1 project and simply updating it to target netcoreapp2.0 and the latest ASP.NET Core 2.0 packages. However, this was problematic since I...
Read More
ASP.NET For Beginners – ASP.NET Core with Docker

ASP.NET For Beginners – ASP.NET Core with Docker

ReviewCoreASPHosting.NET | Best and cheap ASP.NET core 1.0 hosting. In this tutorial, you will learn how to build and run your first asp.net core docker image. You will need to install dotnet core and docker on your machine before you begin this tutorial. If you are running behind a proxy some of the commands might not work, so be sure to check out the Proxy-Section below. The Dockerfile If you already have basic knowledge of Docker skip this introduction and go straight to "Choose an image". You can run one of the many images that exist ready for usage on hub.docker.com. You can for example run a command on an instance of Debian a popular Linux Distro with the following command: docker run debian echo "Welcome to Docker" This might take a while the first time, since docker has to pull the image. A second run should start the command in a fraction of a second. Instead of running a "throw away"-container you can also use an container interactively...
Read More
Create a versioned and documented ASP.NET Core Web API

Create a versioned and documented ASP.NET Core Web API

ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core 1.0 hosting. Let’s create a versioned and semi-automatically documented Web API, this could be done both for public API, and quite useful for, internal-use API’s as well. The ASP.NET Core Web API Project Create a new project Visual C# > .NET Core > ASP.NET Core Web Application and give a descriptive name to your API. We’re going to add three NuGet packages: Install-Package Microsoft.AspNetCore.Mvc.Versioning Install-Package Swashbuckle.AspNetCore -Pre Install-Package SwashbuckleAspNetVersioningShim -Pre Two of these packages are prerelease packages but they are fully functional You can now remove the automatically created ValuesController.cs and let’s add a new HelloController.cs using Microsoft.AspNetCore.Mvc; namespace VersionedWebApi.Controllers { /// <summary> /// HelloController, just saying Hello World! /// </summary> [ApiVersion("1.0", Deprecated = true)] [Route("api/v{version:apiVersion}/[controller]")] public class HelloController : Controller { /// <summary> /// Default Get call returning Hello World! ...
Read More
Guide to RESTful APIs with ASP.NET Core

Guide to RESTful APIs with ASP.NET Core

ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core 1.0 hosting. Microsoft and the .NET community decided to merge the functionality of MVC and Web API in ASP.NET Core when it was released. The two have always been very similar. In this article, we will discuss how to implement a Web API with ASP.NET Core. If you are looking for ASP.NET Core Web API, this is your guide for how to accomplish it. Here is what we are going to cover: Web API vs MVC Migrating Web API to MVC 6 Using ASP.NET Core MVC 6 as a RESTful API MVC 6 alternatives for RESTful APIs ASP.NET Web API vs MVC: What is the Difference? Before ASP.NET Core, they were very similar. Both followed an MVC type pattern with controllers and actions. Web API lacked a view engine like a Razor and instead was designed to be used for REST APIs. MVC was designed for standard web applications with HTML front ends. Microsoft touted Web API...
Read More
Adding MVC to ASP.NET Core web application

Adding MVC to ASP.NET Core web application

ReviewCoreASPHosting.NET | Best and cheap ASP.NET MVC core hosting. This article refers to an earlier version of the .NET Core SDK and project.json which Microsoft has deprecated in favour of a revamped .csproj file. Now let’s add MVC to the picture. Start off by modifying project.json to require the MVC packages. { "version": "1.0.0-*", "buildOptions": { "debugType": "portable", "emitEntryPoint": true }, "dependencies": {}, "frameworks": { "netcoreapp1.0": { "dependencies": { "Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0" }, "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", "Microsoft.AspNetCore.Mvc": "1.0.0" }, "imports": "dnxcore50" } ...
Read More
Integrate Identity with your ASP.NET MVC Application

Integrate Identity with your ASP.NET MVC Application

ReviewCoreASPHosting.NET | Best and cheap ASP.NET MVC hosting. ASP.NET Identity is the new  Microsoft Framework dedicated to the security management of ASP.NET applications : MVC, Web forms, WEB API . This new framework enables efficient and effective security management of ASP.NET applications, and this through: Managing users and their permissions to access ASP.NET applications, Management of entitlements and access rights to the different components of an ASP.NET application. To do this, the ASP.NET Identity framework defines a set of APIs that allows the management of users, roles and their access permissions. By default, MS Identity framework create specific entities and database. Sometimes this will poses problems, especially if we want to integrate the Ms Identity framework entities (users, roles...) with our specific application model. In this article we will see how to integrate the Microsoft Identity framework entities with an ASP.NET MVC application specific model Using the Code First Entity framework approach. To achieve this goal, we will use an ASP.NET MVC application with code first Entity framework approach, with...
Read More
Simple Injector ASP.NET Core MVC Integration NuGet package

Simple Injector ASP.NET Core MVC Integration NuGet package

ReviewCoreASPHosting.NET | Best and cheap ASP.NET Core hosting. The following code snippet shows how to use the integration package to apply Simple Injector to your web application’s Startup class. // You'll need to include the following namespaces using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Mvc.ViewComponents; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using SimpleInjector; using SimpleInjector.Lifestyles; using SimpleInjector.Integration.AspNetCore; using SimpleInjector.Integration.AspNetCore.Mvc; public class Startup { private Container container = new Container(); public Startup(IHostingEnvironment env) { // ASP.NET default stuff here } // This method gets called by the runtime. public void ConfigureServices(IServiceCollection services) { // ASP.NET default stuff here services.AddMvc(); services.AddSingleton<IControllerActivator>( new SimpleInjectorControllerActivator(container)); services.AddSingleton<IViewComponentActivator>( ...
Read More