ASP.NET

1Gig-Tech (#18) – Azure, AWS, CLI, HyperV, async-await, ASP.NET

November 25, 2015 1Gig Tech , , , , ,

Welcome to 1Gig Tech update!

In today’s edition, there are 13 articles on technology, news, open source, community on the fantastic and ever evolving technology world.

  • Sridhar-MS/cli forked from dotnet/cli
    This repo contains the source code for cross-platform .NET Core command line toolchain. It contains the implementation of each command, the native packages for various supported platforms as well as documentation. This toolchain is independent from the DNX-based .NET Core + ASP.NET 5 RC bits.
  • Connect(); // 2015
    Join us this year to hear directly from Scott Guthrie, Brian Harry, and Scott Hanselman on what’s next in this exciting journey. Get deeper insights into our exciting announcements with over 80 on-demand sessions.
  • async/await – What You Should Know! (Amir Dashti)
    Sometimes, we use new technologies while we are not aware of the bottlenecks and weird parts of that technology which eventually might trap us in bad situations like deadlocks which may be really hard to track.
  • An Isomorphic Architecture for ASP.NET MVC
    At the same time, we had long desired the dynamic user interface provided by a Single Page Application, but were unwilling to make the necessary compromises in SEO indexability and initial page load time.
  • Microsoft/vscode
    VS Code is a new type of tool that combines the simplicity of a code editor with what developers need for their core edit-build-debug cycle. Code provides comprehensive editing and debugging support, an extensibility model, and lightweight integration with existing tools.
  • Join Visual Studio Dev Essentials
    Get everything you need to build and deploy your app on any platform. With state-of-the-art tools, the power of the cloud, training, and support, it’s our most comprehensive free developer program ever.
  • Video: Software architecture as code (Simon Brown)
    I presented a new version of my “Software architecture as code” talk at the Devoxx Belgium 2015 conference last week, and the video is already online. If you’re interested in how to communicate software architecture without using tools like Microsoft Visio, you might find it interesting.
  • Ethereum Blockchain as a Service now on Azure
    Microsoft and ConsenSys are partnering to offer Ethereum Blockchain as a Service (EBaaS) on Microsoft Azure so Enterprise clients and developers can have a single click cloud based blockchain developer environment.

You can also follow these updates on Facebook Page or can also read previous editions at 1Gig Tech

Thanks

1Gig-Tech (#16) – Benchmarks, ASPNET, DataFabric

November 3, 2015 1Gig Tech , ,

Welcome to 1Gig Tech update!

In today’s edition, there are 7 articles on technology, news, open source, community on the fantastic and ever evolving technology world.

  • aspnet/benchmarks (DamianEdwards)
    The machines are connected to an 8-port Netgear XS708E 10-Gigabit switch. We’re using wrk to generate load from one of our Linux boxes (usually perfsvr2). We also have WCAT set up on perf02 but it as it doesn’t support HTTP pipelining we’ve stopped using it for now.
  • Install .NET on a Cloud Service Role (Saurabh Bhatia)
    This article describes how to install .NET framework on Cloud Service Web and Worker Roles. You can use these steps to install .NET framework 4.5.2 or .NET 4.6 on the Azure Guest OS Family 4. For the latest information on Guest OS releases see Azure Guest OS Releases and SDK Compatibility Matrix.
  • Announcing .NET Framework 4.6.1 RC (Heath Stewart)
    We are pleased to announce the release of .NET Framework 4.6.1 RC today. This release includes ~150 fixes and some new features. You can read about the new fixes and features that are included in the RC release and try out the bits using the links below.
  • Migrating an ASP.NET MVC 5 App to ASP.NET 5
    ASP.NET 5 is an amazing reinvention of ASP.NET. When targeted against the .NET Core CLR, ASP.NET is cloud-optimized and cross-platform. Many have already written about the virtues of the new platform.
  • David Fowler – ASP.NET 5 Deconstructed (tretton37)
    ASP.NET 5 is an entirely new web stack, rebuilt from the ground up to run fast, cross-platform, and completely configurable. Join David Fowler, one of the architects of ASP.NET 5, as he goes deep into the core of ASP.NET 5. What’s the hosting model? How does the HTTP stack work? How do middleware an

You can also follow these updates on Facebook Page or can also read previous editions at 1Gig Tech

Thanks

1Gig-Tech (#10) – IoT, ASP.NET, StackOverflow, UWP, SideWaffle

September 12, 2015 1Gig Tech , , , ,

Welcome to 1Gig Tech update!

In today’s edition, there are 11 articles on technology, news, open source, community on the fantastic and ever evolving technology world.

  • Hello, Windows 10 IoT Core (Steve Teixeira)
    Greetings, Makers! We are excited to announce the public release of Windows 10 IoT Core for the Raspberry Pi 2 and the MinnowBoard Max. Visit the Windows IoT Dev Center to choose your target board, then walk through the steps to provision your board, acquire the tools, and get started Making.
  • Basic Web API with ASP.NET 5 (elanderson)
    I am going to create basic web API access to the contacts data I have been using in previous posts. To start with I added an API folder to my project to hold my API controller. Next I added a contacts controller to the API folder by right clicking on the folder and selecting add new item.
  • Love 2 Dev – Chris Love’s Modern Web Development Blog
    I enjoy speaking about Web Development topics to user groups and conferences and have been for over 7 years. As I am able to confirm dates and locations I will add them to this page so you can see if I will be in your neck of the woods.
  • MVVM Light V5.2 is live!
    This week I published MVVM Light V5.2 to Nuget and to the Visual Studio Gallery. There are a few highlights which are described as always in the Change Log. See further below for a more detailed explanation of some of the changes.
  • Windows 10 UWP–Migrating a Windows 8.1 App (Part 8 of N)
    Following on from this series of posts; I wanted to experiment a little more with providing a camera ‘wheel’ control on the right hand side of my UI – something a little like the one in the screenshot below – which would allow my user to manually control the focus of the camera on a device
  • Vessyl – Automatically Track Everything You Drink
    Pre-order your Vessyl at http://www.myVessyl.com.Vessyl automatically knows and tracks everything you drink (calories, caffeine, fats, sugars, etc). So whether you want to lose weight, build muscle, regulate caffeine, or stay hydrated, Vessyl helps you keep track of what matters to you… all automa
  • SideWaffle
    The SideWaffle extension adds a bunch of useful Snippets, Project- and Item Templates to Visual Studio. The purpose is to make your daily work in Visual Studio a richer and more productive experience. This is where all the item- and project templates live.

You can also follow these updates on Facebook Page or can also read previous editions at 1Gig Tech

Thanks

1Gig-Tech (#9) – Azure, Node C, NQuery, ASP.NET, PowerShell

September 5, 2015 1Gig Tech , , , ,

Welcome to 1Gig Tech update!

In today’s edition, there are 13 articles on technology, news, open source, community on the fantastic and ever evolving technology world.

  • terrajobst/nquery-vnext (terrajobst)
    This is a Roslyn inspired rewrite of NQuery. The goals are: Expose the internals of the compiler as an object model to support building advanced editor features.
  • Microsoft Free online courses from Microsoft
    “Be passionate and bold. Always keep learning. You stop doing useful things if you don’t learn.” – Satya Nadella, CEO, Microsoft We live in a mobile-first and cloud-first world. Computing is ubiquitous, and experiences span devices and exhibit ambient intelligence.
  • ing Raphael.js Charts in ASP.NET MVC (Mahesh Sabnis)
    Being able to draw graphics and objects in the web browser is something that has become a common phenomenon in today’s web landscape. As web developers working on Line of Business applications (LOB), we are often faced with the task of visually representing huge volumes on data.
  • Announcing Availability of ASP.NET 5 Beta7 (Heath Stewart)
    ASP.NET 5 beta7 is now available both on NuGet and as a tooling update to Visual Studio 2015! This release also includes the first public preview of the .NET Execution Environment (DNX) for Mac and Linux based on .NET Core – no Mono required. Let’s take a look at how we can get started with ASP.
  • PowerShell Script for Restart Windows Services with Dependent Services
    This is a PowerShell Script to restart a windows service with its dependent services. The dependent services that were not running when the restart request made, will not be started, so that the system services state will remain same after restart service script run. Download RestartService.
  • Cloud Explorer for Visual Studio 2013
    Free View your cloud resources, inspect their properties, and perform key developer actions from within Visual Studio. CREATED BY REVIEWS (0) Review SUPPORTS Visual Studio 2013 DOWNLOADS Download (2,604) VERSION 1.0.50825.
  • mateogianolio/node-c
    Embed C functions in JavaScript comments. Should work on Linux and OS X. This is more a proof of concept than something to be used in production. Be careful.
  • UWP: New features of Launcher class (Sergiy Baydachnyy)
    In this post I want to discuss how to establish communications between Universal Windows Platform applications. It was a problem since Windows 8 because each application is running in its own sandbox without access to data of other applications. Of course, Windows 8.
  • .NET Problem Solvers
    Whether you have been a member of the .NET community for ten years or ten days, we solve some amazing problems together. We wanted to take a moment to salute two inspiring problem-solvers that are always looking for new and innovative ways to enhance our community. Thanks you two!
  • Auto-Complete .NET Constructor Params (Jason Shirk.)
    If you’re a regular PowerShell script or module author, you’re probably accustomed to creating .NET objects using object constructors. In the Microsoft .NET Framework, each struct or class can have one or more constructors.

You can also follow these updates on Facebook Page or can also read previous editions at 1Gig Tech

Thank

Scheduling Background Tasks in ASP.NET using Quartz.NET

August 27, 2015 ASP.NET, ASP.NET vNext, Visual Studio , ,

 

Ever wondered how we can have critical tasks (not just sending out newsletters, tweeting, etc.) scheduled as background tasks our an ASP.NET website? This post outlines a quick way to use an open-source tooling to schedule background tasks in not more than 3 steps.

For scheduling background tasks, I recommend using one of the two open-source libraries – Quartz or Hangfire.

If we don’t need any monitoring, are a fan of zero/minimal configuration, don’t have any database or cache, etc. we can choose Quartz otherwise we can use Hangfire. In this post, we will use Quartz as a scheduling framework. To start with, we need to add reference of the NuGet package ‘Quartz’ to our Web Application by typing following command in Package Manager Console (or we can also use the UI in Visual Studio)

Install-Package Quartz

Now, there are 3 steps to adding a background tasks

 

Defining a Job

The beauty about Quartz is that it allows us to define the job in a separate class which ensures right abstraction and encapsulation. So let’s define a MaintenanceJob that inherits the interface IJob which has one member Execute. The method defines the action to be performed when the scheduled job is triggered

using Quartz;
namespace Tasks
{
    public class MaintenanceJob : IJob
    {
       public void Execute(IJobExecutionContext context)
       {
            var ftpLocation = context.JobDetail.JobDataMap.Get("ftp.location");
            // zip old log files
            // delete the files once zip is completed
            // sftp the zip to another location
        }
    }
}

Here, the IJobExecutionContext provides us the context of the job like – JobRunTime, PreviousFireTimeUtc, NextFireTimeUtc, Trigger, JobDetail, etc. JobDetail can be set from Trigger or Scheduler as additional data passed to the scheduled jobs.

Defining a Job Trigger

 

Trigger defines when a Job should be executed. There are different types of triggers – Time based, CRON, Calendar, Schedule, etc.

We want to run this MaintenanceJob once daily (at interval of 24 hours) at midnight. So our trigger definition will look like,

        public static ITrigger TimeTrigger()
        {
            return TriggerBuilder.Create()
               .WithDailyTimeIntervalSchedule
                 (s =>
                    s.WithIntervalInHours(24)
                   .OnEveryDay()
                   .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(0, 0))
                 )
               .Build();
        }

 

When we use Time Interval Schedule, we have many options to schedule this job on weekdays OnMondayThroughFriday or on weekends OnSaturdayAndSunday, every minute/second, etc. If we were to define the trigger using CRON expressions, our trigger will look like,

        public static ITrigger CRONTrigger()
        {
            return TriggerBuilder.Create()
               .WithCronSchedule("0 57 23 ? * *", s=> s.WithMisfireHandlingInstructionDoNothing())
               .Build();
        }

When we use CRON based trigger, we can use CRON expressions to define interval and can also actions to handle failures, etc.  The above expression will run the job every day at 23:57 (server time)

 

Defining a Job Schedule

A scheduler acts as an entry point and definition for all Quartz jobs. So we need to derive a correlation between the job we created and the trigger we defined. This scheduler should be called in the Application Start of our ASP.NET website (Webforms or MVC). Now we can either write the below code directly in Application_Start method in Global.asax or we can structure it in a new class called JobScheduler

    public class JobScheduler
    {
        public static void Start()
        {
            IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
            scheduler.Start();

            IJobDetail job = JobBuilder.Create<MaintenanceJob>().Build();
            job.JobDataMap.Add("ftp.location", "ftp://SomeFileLocation");
            scheduler.ScheduleJob(job, Triggers.TimeTrigger());
        }
    }

In the above code, we are using a scheduler, defining (not creating an object) MaintenanceJob using JobBuilder and associating MaintenanceJob with the TimeTrigger trigger. Next, we need to have this JobScheduler.Start method called when the application starts (i.e. at every IIS reset)

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            JobScheduler.Start();
        }

 

If we need to run tasks on a schedule as part of our ASP.NET application with reliable accuracy and without multiple Batch Scripts or PowerShell scripts running as Scheduled Tasks, choose Quartz. The code is also available as Gist on GitHub

1Gig-Tech (#7) – ASP.NET, CloudFoundry, CSS, VSO

August 23, 2015 1Gig Tech , , ,

Welcome to 1Gig Tech update!

In today’s edition, there are 8 articles on technology, news, open source, community on the fantastic and ever evolving technology world.

  • Cloud Foundry on Azure (RicksterCDN)
    Ning Kuang, Sr. PM on the Azure compute team chats with Rick about the latest release of Cloud Foundry on Microsoft Azure. With this new release, a single Azure ARM template has been updated based on community feedback to deploy multiple VMs to serve as your Cloud Foundry environment.
  • Visual Studio On-Demand Videos “The Big List” (Dmitry Lyalin)
    One of my jobs as a Product Manager for Visual Studio is to enable product team Program Managers and developers to create videos of their new product features, and we’ve been very successful in creating hundreds of these on-demand videos over on Channel 9.

You can also follow these updates on Facebook Page or can also read previous editions at 1Gig Tech

Thanks

1Gig Tech (#4) – VS2015, .NET 4.6, ASP.NET, HTML5, AMQP, NCover, IoT

July 25, 2015 1Gig Tech , , , , , ,

Welcome to 1Gig Tech for 25 Jul, 2015!

In today’s edition, there are 23 articles on technology, news, open source, community on the fantastic and ever evolving technology world.

  • The History of Windows Timeline (cmclellan)
    After April 8 2014, Microsoft will no longer deliver new security updates, non-security hotfixes, free or paid assisted support options and online technical content updates for Windows XP.
  • A Custom Elements-Based HTML5 UI Framework
    Onsen UI is designed and implemented to deliver unprecedented user experience for your apps. Frustrated with the lack of native-like performance? Try Onsen UI and you’ll feel the difference right away. Onsen UI is responsive.
  • AMQP protocol : the builtin type system by examples (ppatierno)
    One of the most interesting features of AMQP protocol is the built in type system that provides a way to represent the AMQP values inside a frame starting from primitive types to custom types (based on our application domain) and composite types (containing fields).
  • VexFlow
    The score below was rendered in your browser. If you’re a programmer interested in rendering music notation in your own applications, take a look at The VexFlow Tutorial.
  • Edit this webpage with your voice
    Commands you can speak Element selection Select the (element) Ex: “select the header” Ex: “select the footer” Select the largest image Select the text (text) Ex: “select the text GET INFORMATION” Ex: “select the text WITH YOUR VOICE” Select its parent Select its first child Select its last child
  • WebAssembly: a binary format for the web (Google)
    WebAssembly (short: wasm) is a new binary format for the web, created by Google, Microsoft, Mozilla and others. It will be used for performance critical code and to compile languages other than JavaScript (especially C/C++) to the web platform. It can be seen as a next step for asm.js [3].
  • Announcing .NET Framework 4.6 (Heath Stewart)
    We’re excited to announce the RTM releases of .NET Framework 4.6 and Visual Studio 2015 today. You can read about the new features or leave that for later and try them out now. The quickest way to get started is to install the free Visual Studio 2015 Community version. With the .NET Framework 4.
  • Same Day Xamarin Support for Visual Studio 2015 (Miguel de Icaza)
    Today, Microsoft is unveiling the final release of Visual Studio 2015 in a global webcast, and we are joining the celebration! Now Released to Market (RTM) for full use in production, Visual Studio 2015 includes many new features and improvements that make it easier to build apps quickly, includin
  • The anatomy of a credit card form (Gabriel Tomescu)
    Paying for something online with a credit card is simple, right? Yes and no. Yes, because we’ve been doing it since the early days of the Internet (e.g. Amazon), and no, because no two credit card forms are alike.
  • Dropdowns Should be the UI of Last Resort (Luke Wroblewski)
    All too often mobile forms make use of dropdown menus for input when simpler or more appropriate controls would work better. Here’s several alternatives to dropdowns to consider in your designs and why. No one likes filling in forms.
  • NCover 5.1 Beta Program
    When we originally released NCover 5 last year, we were excited to share a lot of great new features including Condition Coverage and even more ways to share coverage results across the organization.
  • Merging Dynamic and Static Sites (Raymond Camden)
    Over the past year or so I’ve been fascinated by static site generators. I have a long history of working with dynamic web sites, and static sites were an intriguing change of perspective for me.

You can also follow these updates on Facebook Page or can also read previous editions at 1Gig Tech

Thanks

1Gig-Tech #2 – ASP.NET, Win10, Office 2016, Xamarin, ElasticSearch

July 11, 2015 1Gig Tech , , , ,

Welcome to 1Gig Tech for 11 Jul, 2015!

In today’s edition, there are 15 articles on technology, news, open source, community on the fantastic and ever evolving technology world.

  • Deploying ASP.NET 5 application to Azure Web App with Git
    I haven’t found any official docs about publishing ASP.NET 5 applications to Azure using source control (continuous deployment), but I thought I’ll give it a try. I failed at first and I asked whether it’s even possible on Twitter: Hi @michaldudak that’s a very good question.
  • react-ui-builder
    This tool is a visual builder of React JS components for your web application. In builder you can easily combine available components with each other, and see how they look and feel right on a web page.
  • Don’t Waste Time On Cross Browser Testing
    Browsers Mobile Simulators Reporting Side By Side Find cross-browser issues in minutes Easily switch between all major desktop browsers You don’t need more than 5 minutes to test any website in all major desktop browsers. Anytime all browsers are just 1 click away.
  • Build native iOS, Android and Mac apps in C#
    Mobile development skills are in demand, and Xamarin for Students gives you an edge over the competition. With Xamarin for Students, you can build native iOS, Android, and Windows apps with Xamarin Studio and Visual Studio, for free.
  • Installing Windows 10: A pictorial walkthrough (Ng Chong Seng)
    With Windows 10 for PCs and tablets due end of this month, and the fact that Microsoft is pushing out preview builds left, right, and center recently, we thought it’s time to revisit the installation process to see how it differs from previous versions of Windows and the early WIndows 10 builds.
  • Windows Server 2003 Migration Resources! (Jeffadude)
    It’s hard to believe that it’s been 12 years since we released Windows Server 2003! On March 28th 2003 I received a ship-it award for the role I played in helping to make Windows Server 2003 ready for enterprise customers.

You can also follow these updates on Facebook Page or can also read previous editions at 1Gig Tech

Thanks,
Punit Ganshani

Shell Script to setup .NET on Linux

December 5, 2014 ASP.NET vNext, Mono , , , , ,

If you are scared by the tedious process of setting up Mono, KVM and KRE on Linux or are not aware of how to get started with it, here is your lifesaver – a single Shell script that can do magic for you.  You don’t need to know anything special to run this.  All you need is an access to Linux VM.  Once you have logged in to a VM using any client (like PuTTy) and run the script.

 

#!/bin/bash

clear

PREFIX=$1
VERSION=$2

if [ -z $PREFIX ]; then
  PREFIX="/usr/local/"
fi

if [ -z $VERSION ]; then
  VERSION="3.10.0"
fi


sudo apt-get install make
sudo apt-get install git autoconf libtool automake build-essential mono-devel gettext zip unzip
sudo apt-get install bash zsh curl

sudo mkdir $PREFIX
sudo chown -R `whoami` $PREFIX

PATH=$PREFIX/bin:$PATH
wget http://download.mono-project.com/sources/mono/mono-$VERSION.tar.bz2
tar -xjvf mono-$VERSION.tar.bz2
cd mono-$VERSION
./autogen.sh --prefix=$PREFIX
make
make install

sudo certmgr -ssl -m https://go.microsoft.com
sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
sudo certmgr -ssl -m https://nuget.org
sudo certmgr -ssl -m https://www.myget.org/F/aspnetvnext/

mozroots --import –sync

wget http://dist.libuv.org/dist/v1.0.0-rc1/libuv-v1.0.0-rc1.tar.gz 
tar -xvf libuv-v1.0.0-rc1.tar.gz
cd libuv-v1.0.0-rc1/
./gyp_uv.py -f make -Duv_library=shared_library
make -C out
sudo cp out/Debug/lib.target/libuv.so /usr/lib/libuv.so.1.0.0-rc1
sudo ln -s libuv.so.1.0.0-rc1 /usr/lib/libuv.so.1

curl -sSL https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh & source ~/.kre/kvm/kvm.sh

source ~/.kre/kvm/kvm.sh

kvm upgrade

mono --version


All you have to do is save this file as say SetupDotNetOnLinux.sh and on your Linux VM, execute this script.  It may prompt you for Y/N at times and keep answering Y everytime

Those who need help in executing this script, a short way I use is

chmod u+x SetupDotNetOnLinux.sh
ls -l SetupDotNetOnLinux.sh
sh SetupDotNetOnLinux.sh

There are several other ways of executing scripts on Linux.  A simple article that can be helpful is Creating and running a script

Update – 6 Dec:  Added script for Libuv.  Thanks to David Fowler for pointing it.
Also script is available on GitHub.  Any suggestions to improve it, please fork the script 🙂

Hosting your ASP.NET application on Azure Linux Hosting

December 1, 2014 ASP.NET, Azure, Visual Studio, Xamarin , , , , , , ,

Now that ASP.NET 5.0 (vNext) runs on .NET 2015 – a cross platform version of .NET – it is worthwhile hosting your web applications on Linux. So let’s get started

Procuring a Linux VM

I chose procuring a Linux VM using my Azure Subscription and I quickly spawned a Standard Ubuntu server.

Now what you get as a VM is basic version of VM and you need to install .NET runtime on it.

 

Installing .NET Runtime on Linux VM

If you do not have PuTTY client, I would recommend downloading it as we will use this for executing all our commands on Linux. Using PuTTY, you can login using your SSH certificate or credentials (based on your VM configuration). First you need to validate if you have appropriate version of Mono installed by executing following command

mono --version

You will get an output like,

The minimum required version of Mono for ASP.NET 5.0 is 3.4.1 or later. So in this case, we do need to install a later version of Mono. You can execute following commands one by one on the VM

## Prerequisites

sudo apt-get install make
 sudo apt-get install git autoconf libtool automake build-essential mono-devel gettext zip mono-complete unzip
 sudo apt-get install bash zsh curl

## Get Mono Code and Compile it

PREFIX=/usr/local
PATH=$PREFIX/bin:$PATH
VERSION=3.10.0
wget http://download.mono-project.com/sources/mono/mono-$VERSION.tar.bz2
tar -xjvf mono-$VERSION.tar.bz2
cd mono-$VERSION
./autogen.sh --prefix=$PREFIX
make
make install

These steps would require around 45-60 minutes of time and would download latest source code of Mono from GitHub, compile and install it for you on your VM. The source code is huge and its compilation (command: make) will take time to execute. You can browse through different versions of Mono at – http://download.mono-project.com/sources/mono/

The .NET Framework on Windows uses the Windows Certificates store to check whether to accept an SSL certificate from a remote site. In Mono, there is no Windows Certificate store, it has its own store. By default, it is empty and we need to manage the entries ourselves.

sudo certmgr -ssl -m https://go.microsoft.com
sudo certmgr -ssl -m https://nugetgallery.blob.core.windows.net
sudo certmgr -ssl -m https://nuget.org
sudo certmgr -ssl -m https://www.myget.org/F/aspnetvnext/

This would ask you if you want to import certificates to CA store and AddressBook store. Say Y when prompted. In total, 9 certificates will be imported.

Some of the certificates may not be trusted, so to avoid trust issues you need to execute

mozroots --import –sync

 

Installing K-Version Manager

Installing KVM is simple and is single line command

curl -sSL https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh & source ~/.kre/kvm/kvm.sh

Post this you have to execute following command to start kvm

source /home/punitganshani/.kre/kvm/kvm.sh

Now you can trigger another command to upgrade kvm

kvm upgrade

This command will download the specified version of the K Runtime Environment (KRE), and put it on your user profile ready to use.

After all the above steps are completed, you can execute below command to check the version of Mono installed

mono --version

You should get some output like,

Verify K Runtime Environment (KRE)

 

The KVM upgrade command will download K Runtime Environment (KRE) and put it on your user profile to use. So next is to verify if K has been installed correctly

Checking nuget.config file

 

In the /home/<<username>>/.config/NuGet folder, you will find nuget.config.
The content of files should appear as


 
 
 
 
 


Hosting your ASP.NET 5.0 Website

 

So for illustration, I am using ASP.NET 5.0 Starter Application which can be quickly created using VS 2015 and its solution structure looks like,

I need to send this code to my Linux VM for compilation. I use FileZilla to connect to FTP to my sites. So I created another folder on my VM /home/punitganshani/punit/aspnet where I will copy my solution code. Once the code has been copied to the VM, you need to ensure that you have the correct Nuget Packages which can be verified and updated using

kpm restore –s www.myget.org/F/aspnetvnext/

Before you run this command, make sure your project.json has following elements

"dependencies": {
    "Kestrel": "1.0.0-beta1",
 },
 "commands": {
    "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
    "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5000"
 },

The command kestrel will not be available in KRE unless you have defined the Kestrel in project.json. If you haven’t mentioned Kestrel, you will have to manually install it using following commands,

sudo apt-get install npm
npm install -g grunt-cli
npm install kestrel-server

Now you can compile the code using command

kpm build

With the build being successful, now we can host the application,

k kerstel

For a website that ran perfectly through Visual Studio, you may get an error

System.NullReferenceException: Object reference not set to an instance of an object at Microsoft.AspNet.Server.Kestrel.Networking.Libuv.loop_size ()
 [0x00000] in <filename unknown>:0 at
 Microsoft.AspNet.Server.Kestrel.Networking.UvLoopHandle.Init (Microsoft.AspNet.Server.Kestrel.Networking.Libuv uv) [0x00000] in <filename unknown>:0 at Microsoft.AspNet.Server.Kestrel.KestrelThread.ThreadStart (System.Object parameter) [0x00000] in <filename unknown>:0

You can enable tracing to get more details by executing command export KRE_TRACE=1

For Web Applications, we need KestrelHttpServer which is built on libuv library. So let’s build libuv and get going,

wget http://dist.libuv.org/dist/v1.0.0-rc1/libuv-v1.0.0-rc1.tar.gz
tar -xvf libuv-v1.0.0-rc1.tar.gz
cd libuv-v1.0.0-rc1/
./gyp_uv.py -f make -Duv_library=shared_library
make -C out
sudo cp out/Debug/lib.target/libuv.so /usr/lib/libuv.so.1.0.0-rc1
sudo ln -s libuv.so.1.0.0-rc1 /usr/lib/libuv.so.1

And we run the same command k kerstel

The last bit, exposing endpoint on Azure

 

As per the project.json we have hosted this website on the port 5000 using kestrel, so we need to expose this endpoint to the users. Assuming that this VM will host only one website, we can setup a HTTP/TCP endpoint as

You are now set to browse the ASP.NET 5.0 application hosted on Linux

The sample source code for project.json and packages.config are available on GitHub

Follow on Feedly