How to deploy a self contained .NET Core app.

in ASP.NET MVC
by Mahmut Jomaa on June 27, 2016
mnwall-separatormnwall-separator
Ok this blog post is rather a duplicate of the docs. However many people wrote me an e-mail because they simply didn't find it.   Docs: https://docs.microsoft.com/en-us/dotnet/articles/core/deploying/index   1. Change the…

.NET Core 1.0 got released

in News
by Mahmut Jomaa on June 27, 2016
mnwall-separatormnwall-separator
Today is the day. Microsoft announced something sweet at Red Hat DevNation. After a 3 year long journey .NET Core 1.0 got released: https://blogs.msdn.microsoft.com/dotnet/2016/06/27/announcing-net-core-1-0/     1. Get the Visual…

Microsoft aquired Xamarin

in News
by Mahmut Jomaa on February 25, 2016
mnwall-separatormnwall-separator
Microsoft announced today that they aquired Xamarin. This is HUGE!   About Xamarin Xamarin is a provider for mobile app development technology. You can write a C# application and cross-compile…

Building a simple Brainfuck Interpreter in C

in C/C++
by Mahmut Jomaa on December 08, 2015
mnwall-separatormnwall-separator
Brainfuck is a Turing-complete language that isn't necessary designed for productive usage :) However it is actually great to understand C pointers. An Interpreter is a computer program that directly…

How to enable precompiled razor views (.cshtml) in ASP.NET 5

in ASP.NET MVC
by Mahmut Jomaa on November 29, 2015
mnwall-separatormnwall-separator
If you want your .cshtml to be precompiled before the first request hits, you need to enable it manually. This increases time needed for compilation, however the compilation process still…

Upgrading your ASP.NET 5 application from beta8 to RC1

in ASP.NET MVC
by Mahmut Jomaa on November 23, 2015
mnwall-separatormnwall-separator
There aren't that many API changes, the focus on RC1 was to stabilize the code base.   Installation of RC1: 1. First download and install the RC1 upgrade for Visual…

Pasterino.com

in Projects
by Mahmut Jomaa on November 09, 2015
mnwall-separatormnwall-separator
Today I'm releasing a new online tool: pasterino.com In short: You can store text online or use it as your syntax highlghter (for your blog).   Features: Paste and share…

Tag Helpers in ASP.NET 5

The version 6.0 of the MVC framework (Model View Controller) in ASP.NET 5.0 provides a new approach for reusable components in the form of so-called Tag Helpers (not to be confused with HTML Helpers that are already available in ASP.NET MVC since version 1.0). Software developer can now define a new HTML tag or extend existing ones, which will be replaced on the server side before delivering the HTML page to the client.

This is comparable to the directives in angularjs. However, angularjs is a JavaScript framework that translates on the client side (ie in the browser).

 

In Short:

Basically TagHelper allow you to create own server side tags in your Razor views. It's far less complex and feels much more like second nature.

 

 So this

@Html.ActionLink("About us", "About", "Home")

 Can now be written as

<a asp-controller="Home" asp-action="About">About us</a>

 

The HTML result in both cases is

<a href="/Home/About">About us</a>

 

 

Define your own Tag Helper:

Let's write a simple Tag Helper. I assume that most people know about Twitter Bootstrap. It's a column based framework used on many sites.

 

Usually when we declare a new row we write

<div class="row">
    //...
</div>

 

Now we want that to be shortened to

<row>
    //...
</row>

 

 

We do this is by creating a new C# class that derives from TagHelper

 

 

Fine tuning:

That's crazy because ASP.NET 5 has little to no Overhead. It's very lean and modular. However we can help the server to tell him what and what not to process to save some resources.

 

Option 1: Tell the server what not to process.:

<!a href="http://google.com">Porn Machine</!a>

 

Option 2: Or you can tell the server what to process (opposite)

Add this line to your _GlobalImports.cshtml (Beta5+ it's renamed to _ViewImports.cshtml)

@tagHelperPrefix "do-"

 Now we can tell the server what to process:

<do-a asp-controller="Home" asp-action="About">About us</do-a>

 



Mahmut Jomaa is a Software Engineer from Germany.

Currently he attends university to gain more knowledge in Computer Science.


Security code Refresh

 

Because insights are awesome!