Skip to content

Feed aggregator

Text to Speech (and more) with Windows 10 UWP & ‘Project Oxford’

Mike Taulty's Blog - 3 hours 53 min ago
We’re increasingly talking to machines and, more importantly, they’re increasingly listening and even starting to understand. In the world of the Windows 10 Universal Windows Platform, there’s the SpeechRecognizer class which can do speech recognition on the device without necessarily calling off to the cloud and it has a number of different capabilities. The recognizer … Continue reading Text to Speech (and more) with Windows 10 UWP & ‘Project Oxford’ →
Categories: Blogs

ASP.NET Community Standup – February 2, 2016

Visual Web Developer Team Blog - 6 hours 2 min ago

This is the next in a series of blog posts that will cover the topics discussed in the ASP.NET Community Standup.  The community standup is a short video-based discussion with some of the leaders of the ASP.NET development teams covering the accomplishments of the team on the new ASP.NET 5 framework over the previous week.  Within 30 minutes, Scott HanselmanDamian EdwardsJon Galloway and an occasional guest or two discuss new features and ask for feedback on important decisions being made by the ASP.NET development teams.

Each week the standup is hosted live on Google Hangouts and the team publishes the recorded video of their discussion to YouTube for later reference. The guys answer your questions LIVE and unfiltered.  This is your chance to ask about the why and what of ASP.NET!  Join them each Tuesday on live.asp.net where the meeting’s schedule is posted and hosted.

This week’s meeting is below:

The team started with an initial discussion of the MSDN WebDev blog post – “An Update on ASP.NET Core and .NET Core” The team previously assumed that folks would watch the standup video, and have resolved to publish a blog post and we will continue to publish show notes on the webdev blog so that the show information can be more search-engine friendly. The team is improving messaging about the projects, and we plan to significantly improve it in the weeks ahead.

Some developers feel hurt by the changes in the ASP.NET Core renaming and schedule. Some customers have been very successful with ASP.NET 5 and the transition to ASP.NET Core has not affected them at all. The project is still early, not released and fully supported yet. If you need to avoid any significant changes to your framework, this framework is not for you yet. ASP.NET 4.6 is rock solid and does not have any large API changes happening. The team is learning how to make this style of development work, and they are getting closer to a better development model.

 

Links of the Week:

Steve Desmond wrote Performance is Paramount  about adding some static caching and tuning to his web server significantly improved his performance.  Damian commented that Response Caching is not available yet, but will be coming as part of the framework.

K. Scott Allen shared Downloading and serving node resources in an ASP.NET Core application

Questions and Answers:

Question: “Be Part of the Conversation” overlay on YouTube is annoying
— This is how Google wants you to join the interactive conversation on Google Hangouts

Question: Did I miss the story of RC2?
— Watch last weeks video and read the blog post.  Re-platforming on .NET CLI is taking longer than expected, and to ensure that we will deliver a killer product we are backing off on the timeline and will issue dates when we are confident

Question: What’s the story about LightSwitch HTML?
— We are not involved with that team.  Ask Beth Massi for more details

Question: Any plans on allowing input pass-through of JSON.NET’s type-handling setting in MVC?
— Nothing specifically, MVC options available when configuring your app are exposed and you can plug that with the configuration you need.

Question: WebAPI as a product keeps being mentioned – but is not a product, its merged with MVC. Doesn’t this add to confusion?
— Naming is hard – ASP.NET Core has MVC features and WebAPI features (from the previous versions).  What is meant is that ASP.NET Core includes these things by default now.

Question: Will we see a configuration where we can point IIS to a directory and it just runs?
— We want this to be the finished product, but is still in progress.  The IIS platform handler needs to be configured to call the appropriate executable to host the application.  If the platform handler is installed, a properly loaded web.config with information for IIS in your project should enable this process.
Follow-up question: Will you have to use a ‘publish gesture’ to make this work?
—- You can configure a web.config with all of the options you need, and in theory deliver that file with your application to configure IIS properly

Question: When will ASP.NET Core ‘Hello World’ work with .NET Native?
— Not in scope for RTM.  The demo video on Channel 9 was a hack to show a proof-of-concept and is not being developed actively.

Question: Starting a personal project, a simple web app — should I start now with RC1 Update 1?
— Depends on your tolerance – the big rename update for your code will be addressed in a guide that will be shared when the RC2 ships.  If you like the experience in RC1, you should like the experience in RC2.  You will have some work to update to RC2 but we do not believe it will be difficult.

Question: I am porting a BIG enterprise app comprised of multiple ASP.NET apps in virtual directories.  Will we see support for support sharing or virtual directories in Kestrel?
— No support for port sharing in Kestrel, that’s an Http.Sys feature.  You can achieve both of these with IIS, and you should use those features in IIS.  We’re working to get IISExpress to work properly with the RC2, and will have more details about IIS Express and IIS when the RC2 is ready.  We want to be able to deliver a solution that supports hosting separate ASP.NET Core applications as virtual directories in the same IIS application.

Question: Any tools for ASP.NET Core that are recommended for tracking down memory leaks?
— The team is using dotPeek and dotMemory from JetBrains.  The Visual Studio tools work very well also, and the team uses all of them were each is better.  There are no great tools for Linux yet, but the team is using perf and the Mono tools to diagnose.

Question: Any update on the .tfignore issue?  AspNet/Tooling#18
— No update — we will follow-up

Question: I want to run ASP.NET Core as a desktop app and I need the context of the current user…
— This is how ASP.NET Core is currently recommended to be run – as a console application

Question: Should you use ConfigureAwait(false) in ASP.NET Core?
— No – this is primarily for use when a synchronization context is in use, and that’s not the case in ASP.NET Core.

Question: VS Crashes at least 5 times a day for me, why don’t you have these problems?
— This is typically a problem with extensions or environments.  We recommend that you try shutting off some extensions to see if that helps. Scott will follow-up with this caller.

Question: Is there any OData in the new WebAPI
— No — not yet

Question: Is VSCode broken on Linux, it doesn’t work for me?
— Reach out to @code to ask for help.  Lots of folks are finding success, the @Code team can help.

Question: What about code-contracts on ASP.NET Core?
— No idea.. Ask a question on the ASP.NET Home Repo

Question: Is the .NET Platform Standard being discussed anywhere?  The working docs are not being updated
— That’s right — its being implemented now

Question: How do you catch global exceptions, previously this could be checked in AppDomain.CurrentDomain?
— There is an issue on corefx discussing this right now

Question: The .NET CLI supports vbc, can I run an ASP.NET Core application on VB?
— Not yet.  The team needs to connect the end-to-end pieces to make that work.

Question: VS 2015 community and 2013 community running very slow when debugging with the HD thrashing
— We recommend using SSDs because they improve performance significantly.  Also, Scott recommends going into Windows Defender or any other anti-virus is thrashing your build process.  Scott excludes Devenv, MsBuild, compilers, and the folder that code is in.  If not on an SSD, Scott recommends creating a 2GB memory disk and moving your compile process there.  Also, try running the SysInternals process monitor and see what the disk is doing.  Scott found a backup application was causing his VS problems in the past.

Question: I want to use EF7, but I need to do spatial queries.
— Ask a question about spatial on EF Core GitHub repo.  Jon also points out that there is a way to run EF6 with ASP.NET Core

Question: How do we build ASP.NET Core applications from TFS services that are not exposed to the internet?
— Set up a local feed of NuGet packages inside your firewall and point your build agent at that

Question: People on Reddit and Blogs are obsessed with Native compilation into a single binary
— Neat, but not critical to ASP.NET success right now

Question: It feels like EF7 is not ready enough…
— We need more details about this in a focused discussion of those needs.  The team is focusing on the top 80% of features that applications need, and some features will not make the initial cut.

Question: I like the startup class features in ASP.NET Core like ConfigureServices, but when creating a Console app it doesn’t exist.  It would be nice to have consistency.
— The primitives that support ConfigureServices and DI are part of the web framework and are not in the console app.  You can add those features into a framework for a console application

The next ASP.NET Community Standup will be held live on Feb 16, 2016 from live.asp.net  Check in there to get the exact time in your timezone.  Join us, talk with the team and learn the latest about ASP.NET

// // // // // // // // // // // //

// // // // // // // // // // // //

// // // // // // // // // // // //

// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i// <![CDATA[ if (typeof(lpcurruser) == 'undefined') lpcurruser = ''; if (document.getElementById('lpcurruserelt') && document.getElementById('lpcurruserelt').value != '') { lpcurruser = document.getElementById('lpcurruserelt').value; document.getElementById('lpcurruserelt').value = ''; } if (typeof(lpcurrpass) == 'undefined') lpcurrpass=''; if (document.getElementById('lpcurrpasselt') && document.getElementById('lpcurrpasselt').value != '') { lpcurrpass = document.getElementById('lpcurrpasselt').value; document.getElementById('lpcurrpasselt').value = ''; } var lploc="1";var lponlyfill=null;var link=document.getElementById("i1668"); if(link&&typeof(g_lpclicked)=="undefined"){if(document.createEventObject){var evt = document.createEventObject();link.fireEvent("onclick",evt);}else{var evt2 = document.createEvent("MouseEvents");evt2.initMouseEvent("click", true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);link.dispatchEvent(evt2);}g_lpclicked=1;} if(lploc==3){var pholders=["idDiv_PWD_UsernameExample","idDiv_PWD_PasswordExample","i0116_hint","i0118_hint"]; for(var i=0;i

Categories: Companies

Build Apps with AngularJS on ASP.NET

.NET TV - 8 hours 55 min ago
Learn how to build end-to-end apps using AngularJS and BreezeJS on the ASP.NET platform. We explore how to manage multiple screens, maintain clean code with popular patterns, implement CRUD, perform robust HTML validation, and use local storage for saving work in progress. Video producer: http://msteched.com
Categories: Blogs

Creating a simple ASP.NET 5 Markdown TagHelper

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

I've been dabbling a bit with the new ASP.NET 5 TagHelpers and I was wondering how easy it would be to create one.

I've created a simple Markdown TagHelper with the CommonMark implementation.

So let me show you what it is, what each line of code is doing and how to implement it in an ASP.NET MVC 6 application.

The Code
using CommonMark;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;

namespace My.TagHelpers
{
    [HtmlTargetElement("markdown")]
    public class MarkdownTagHelper : TagHelper
    {
        public ModelExpression Content { get; set; }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagMode = TagMode.SelfClosing;
            output.TagName = null;

            var markdown = Content.Model.ToString();
            var html = CommonMarkConverter.Convert(markdown);
            output.Content.SetContentEncoded(html);
        }
    }
}
Inspecting the code

Let's start with the HtmlTargetElementAttribute. This will wire the HTML Tag <markdown></markdown> to be interpreted and processed by this class. There is nothing stop you from actually having more than one target.

You could for example target element <md></md> by just adding [HtmlTargetElement("md")] and it would support both tags without any other changes.

The Content property will allow you to write code like this:

@model MyClass

<markdown content="@ViewData["markdown"]"></markdown>    
<markdown content="Markdown"></markdown>    

This easily allows you to use your model or any server-side code without having to handle data mapping manually.

TagMode.SelfClosing will force the HTML to use self-closing tag rather than having content inside (which we're not going to use anyway). So now we have this:

<markdown content="Markdown" />

All the remaining lines of code are dedicated to making sure that the content we render is actual HTML. output.TagName just make sure that we do not render the actual markdown tag.

And... that's it. Our code is complete.

Activating it

Now you can't just go and create TagHelpers and have them automatically served without wiring one thing.

In your ASP.NET 5 projects, go to /Views/_ViewImports.cshtml.

You should see something like this:

@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"

This will load all TagHelpers from the Microsoft.AspNet.Mvc.TagHelpers assembly.

Just duplicate the line and type-in your assembly name.

Then in your Razor code you can have the code bellow:

public class MyClass
{
    public string Markdown { get; set; }
}
@model MyClass
@{
    ViewData["Title"] = "About";
}
<h2>@ViewData["Title"].</h2>  

<markdown content="Markdown"/>

Which will output your markdown formatted as HTML.

Now whether you load your markdown from files, database or anywhere... you can have your user write rich text in any text box and have your application generate safe HTML.

Components used
Categories: Blogs

Should our front-end websites be server-side at all?

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

I’ve been toying around with projects like Jekyll, Hexo and even some hand-rolled software that will generate me HTML files based on data. The thought that crossed my mind was…

Why do we need dynamically generated HTML again?

Let me take examples and build my case.

Example 1: Blog

Of course the simpler examples like blogs could literally all be static. If you need comments, then you could go with a system like Disqus. This is quite literally one of the only part of your system that is dynamic.

RSS feed? Generated from posts. Posts themselves? Could be automatically generated from a databases or Markdown files periodically. The resulting output can be hosted on a Raspberry Pi without any issues.

Example 2: E-Commerce

This one is more of a problem. Here are the things that don’t change a lot. Products. OK, they may change but do you need to have your site updated right this second? Can it wait a minute? Then all the “product pages” could literally be static pages.

Product reviews? They will need to be “approved” anyway before you want them live. Put them in a servier-side queue, and regenerate the product page with the updated review once it’s done.

There’s 3 things that I see that would require to be dynamic in this scenario.

Search, Checkout and Reviews. Search because as your products scales up, so does your data. Doing the search client side won’t scale at any level. Checkout because we are now handling an actual order and it needs a server components. Reviews because we’ll need to approve and publish them.

In this scenario, only the Search is the actual “Read” component that is now server side. Everything else? Pre-generated. Even if the search is bringing you the list of product dynamically, it can still end up on a static page.

All the other write components? Queued server side to be processed by the business itself with either Azure or an off-site component.

All the backend side of the business (managing products, availability, sales, whatnot, etc.) will need a management UI that will be 100% dynamic (read/write).

Question

So… do we need dynamic front-end with the latest server framework? On the public facing too or just the backend?

If you want to discuss it, Tweet me at @MaximRouiller.

Categories: Blogs

You should not be using WebComponents yet

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

Have you read about WebComponents? It sounds like something that we all tried to achieve on the web since... well... a long time.

If you take a look at the specification, it's hosted on the W3C website. It smell like a real specification. It looks like a real specification.

The only issue is that Web Components is really four specifications. Let's take a look at all four of them.

Reviewing the specificationsHTML Templates

Specification

This specific specification is not part of the "Web components" section. It has been integrated in HTML5. Henceforth, this one is safe.

Custom Elements

Specification

This specification is for review and not for implementation!

Alright no let's not touch this yet.

Shadow DOM

Specification

This specification is for review and not for implementation!

Wow. Okay so this is out of the window too.

HTML Imports

Specification

This one is still a working draft so it hasn't been retired or anything yet. Sounds good!

Getting into more details

So open all of those specifications. Go ahead. I want you to read one section in particular and it's the author/editors section. What do we learn? That those specs were draft, edited and all done by the Google Chrome Team. Except maybe HTML Templates which has Tony Ross (previously PM on the Internet Explorer Team).

What about browser support?

Chrome has all the spec already implemented.

Firefox implemented it but put it behind a flag (about:config, search for properties dom.webcomponents.enabled)

Internet Explorer, they are all Under Consideration

What that tells us

Google is pushing for a standard. Hard. They built the spec, pushing the spec also very hary since all of this is available in Chrome STABLE right now. No other vendors has contributed to the spec itself. Polymer is also a project that is built around WebComponents and it's built by... well the Chrome team.

That tells me that nobody right now should be implementing this in production. If you want to contribute to the spec, fine. But WebComponents are not to be used.

Otherwise, we're only getting in the same issue we were in 10-20 years ago with Internet Explorer and we know it's a painful path.

What is wrong right now with WebComponents

First, it's not cross platform. We handled that in the past. That's not something to stop us.

Second, the current specification is being implemented in Chrome as if it was recommended by the W3C (it is not). Which may lead us to change in the specification which may render your current implementation completely inoperable.

Third, there's no guarantee that the current spec is going to even be accepted by the other browsers. If we get there and Chrome doesn't move, we're back to Internet Explorer 6 era but this time with Chrome.

What should I do?

As for what "Production" is concerned, do not use WebComponents directly. Also, avoid Polymer as it's only a simple wrapper around WebComponents (even with the polyfills).

Use other framework that abstract away the WebComponents part. Frameworks like X-Tag or Brick. That way you can benefit from the feature without learning a specification that may be obsolete very quickly or not implemented at all.

Categories: Blogs

Fix: Error occurred during a cryptographic operation.

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

Have you ever had this error while switching between projects using the Identity authentication?

Are you still wondering what it is and why it happens?

Clear your cookies. The FedAuth cookie is encrypted using the defined machine key in your web.config. If there is none defined in your web.config, it will use a common one. If the key used to encrypt isn't the same used to decrypt?

Boom goes the dynamite.

Categories: Blogs

Renewed MVP ASP.NET/IIS 2015

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

Well there it goes again. It was just confirmed that I am renewed as an MVP for the next 12 months.

Becoming an MVP is not an easy task. Offline conferences, blogs, Twitter, helping manage a user group. All of this is done in my free time and it requires a lot of time.But I'm so glad to be part of the big MVP family once again!

Thanks to all of you who interacted with me last year, let's do it again this year!

Categories: Blogs

Failed to delete web hosting plan Default: Server farm 'Default' cannot be deleted because it has sites assigned to it

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

So I had this issue where I was moving web apps between hosting plans. As they were all transferred, I wondered why it refused to delete them with this error message.

After a few click left and right and a lot of wasted time, I found this blog post that provides a script to help you debug and the exact explanation as to why it doesn't work.

To make things quick, it's all about "Deployment Slots". Among other things, they have their own serverFarm setting and they will not change when you change their parents in Powershell (haven't tried by the portal).

Here's a copy of the script from Harikharan Krishnaraju for future references:

Switch-AzureMode AzureResourceManager
$Resource = Get-AzureResource

foreach ($item in $Resource)
{
	if ($item.ResourceType -Match "Microsoft.Web/sites/slots")
	{
		$plan=(Get-AzureResource -Name $item.Name -ResourceGroupName $item.ResourceGroupName -ResourceType $item.ResourceType -ParentResource $item.ParentResource -ApiVersion 2014-04-01).Properties.webHostingPlan;
		write-host "WebHostingPlan " $plan " under site " $item.ParentResource " for deployment slot " $item.Name ;
	}

	elseif ($item.ResourceType -Match "Microsoft.Web/sites")
	{
		$plan=(Get-AzureResource -Name $item.Name -ResourceGroupName $item.ResourceGroupName -ResourceType $item.ResourceType -ApiVersion 2014-04-01).Properties.webHostingPlan;
		write-host "WebHostingPlan " $plan " under site " $item.Name ;
	}
}
      
    
Categories: Blogs

Switching Azure Web Apps from one App Service Plan to another

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

So I had to do some change to App Service Plan for one of my client. The first thing I was looking for was to do it under the portal. A few clicks and I'm done!

But before I get into why I need to move one of them, I'll need to tell you about why I needed to move 20 of them.

Consolidating the farm

First, my client had a lot of WebApps deployed left and right in different "Default" ServicePlan. Most were created automatically by scripts or even Visual Studio. Each had different instance size and difference scaling capabilities.

We needed a way to standardize how we scale and especially the size on which we deployed. So we came down with a list of different hosting plans that we needed, the list of apps that would need to be moved and on which hosting plan they currently were.

That list went to 20 web apps to move. The portal wasn't going to cut it. It was time to bring in the big guns.

Powershell

Powershell is the Command Line for Windows. It's powered by awesomeness and cats riding unicorns. It allows you to do thing like remote control Azure, import/export CSV files and so much more.

CSV and Azure is what I needed. Since we built a list of web apps to migrate in Excel, CSV was the way to go.

The Code or rather, The Script

What follows is what is being used. It's heavily inspired of what was found online.

My CSV file has 3 columns: App, ServicePlanSource and ServicePlanDestination. Only two are used for the actual command. I could have made this command more generic but since I was working with apps in EastUS only, well... I didn't need more.

This script should be considered as "Works on my machine". Haven't tested all the edge cases.

Param(
    [Parameter(Mandatory=$True)]
    [string]$filename
)

Switch-AzureMode AzureResourceManager
$rgn = 'Default-Web-EastUS'

$allAppsToMigrate = Import-Csv $filename
foreach($app in $allAppsToMigrate)
{
    if($app.ServicePlanSource -ne $app.ServicePlanDestination)
    {
        $appName = $app.App
		    $source = $app.ServicePlanSource
		    $dest = $app.ServicePlanDestination
        $res = Get-AzureResource -Name $appName -ResourceGroupName $rgn -ResourceType Microsoft.Web/sites -ApiVersion 2014-04-01
        $prop = @{ 'serverFarm' = $dest}
        $res = Set-AzureResource -Name $appName -ResourceGroupName $rgn -ResourceType Microsoft.Web/sites -ApiVersion 2014-04-01 -PropertyObject $prop
        Write-Host "Moved $appName from $source to $dest"
    }
}
    
Categories: Blogs

Microsoft Virtual Academy Links for 2014

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

So I thought that going through a few Microsoft Virtual Academy links could help some of you.

Here are the links I think deserve at least a click. If you find them interesting, let me know!

Categories: Blogs

Temporarily ignore SSL certificate problem in Git under Windows

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

So I've encountered the following issue:

fatal: unable to access 'https://myurl/myproject.git/': SSL certificate problem: unable to get local issuer certificate

Basically, we're working on a local Git Stash project and the certificates changed. While they were working to fix the issues, we had to keep working.

So I know that the server is not compromised (I talked to IT). How do I say "ignore it please"?

Temporary solution

This is because you know they are going to fix it.

PowerShell code:

$env:GIT_SSL_NO_VERIFY = "true"

CMD code:

SET GIT_SSL_NO_VERIFY=true

This will get you up and running as long as you don’t close the command window. This variable will be reset to nothing as soon as you close it.

Permanent solution

Fix your certificates. Oh… you mean it’s self signed and you will forever use that one? Install it on all machines.

Seriously. I won’t show you how to permanently ignore certificates. Fix your certificate situation because trusting ALL certificates without caring if they are valid or not is juts plain dangerous.

Fix it.

NOW.

Categories: Blogs

The Yoda Condition

Decaying Code - Maxime Rouiller - 12 hours 16 min ago

So this will be a short post. I would like to introduce a word in my vocabulary and yours too if it didn't already exist.

First I would like to credit Nathan Smith for teaching me that word this morning. First, the tweet:

Chuckling at "disallowYodaConditions" in JSCS… https://t.co/unhgFdMCrh — Awesome way of describing it. pic.twitter.com/KDPxpdB3UE

— Nathan Smith (@nathansmith) November 12, 2014

So... this made me chuckle.

What is the Yoda Condition?

The Yoda Condition can be summarized into "inverting the parameters compared in a conditional".

Let's say I have this code:

string sky = "blue";if(sky == "blue) {    // do something}

It can be read easily as "If the sky is blue". Now let's put some Yoda into it!

Our code becomes :

string sky = "blue";	if("blue" == sky){    // do something}

Now our code read as "If blue is the sky". And that's why we call it Yoda condition.

Why would I do that?

First, if you're missing an "=" in your code, it will fail at compile time since you can't assign a variable to a literal string. It can also avoid certain null reference error.

What's the cost of doing this then?

Beside getting on the nerves of all the programmers in your team? You reduce the readability of your code by a huge factor.

Each developer on your team will hit a snag on every if since they will have to learn how to speak "Yoda" with your code.

So what should I do?

Avoid it. At all cost. Readability is the most important thing in your code. To be honest, you're not going to be the only guy/girl maintaining that app for years to come. Make it easy for the maintainer and remove that Yoda talk.

The problem this kind of code solve isn't worth the readability you are losing.

Categories: Blogs

Dynamic code generation in C#

Ayende @ Rahien - 17 hours 8 min ago

Let us assume that we have the following simple task:

Given a Dictionary<string, string>, convert that dictionary into a type in as performant a manner as possible. The conversion will happen many time, and first time costs are acceptable.

The answer we came up with is to dynamically generate the code based on the type. Basically, here is how it looks like:

public static Func<Dictionary<string, string>, T> Generate<T>()
    where T : new()
{
    var dic = Expression.Parameter(typeof (Dictionary<string, string>), "dic");
    var tmpVal = Expression.Parameter(typeof (string), "tmp");
    var args = new List<MemberAssignment>();
    foreach (var propertyInfo in typeof(T).GetProperties())
    {
        var tryGet = Expression.Call(dic, "TryGetValue", new Type[0], 
            Expression.Constant(propertyInfo.Name),
            tmpVal);

        Expression value = tmpVal;
        if (propertyInfo.PropertyType != typeof (string))
        {
            var convertCall = Expression.Call(typeof(Convert).GetMethod("ChangeType", 
                new Type[] { typeof(object), typeof(Type) }), tmpVal,
                Expression.Constant(propertyInfo.PropertyType));
            value = Expression.Convert(convertCall, propertyInfo.PropertyType);
        }

        var conditional = Expression.Condition(tryGet, value, 
            Expression.Default(propertyInfo.PropertyType));

        args.Add(Expression.Bind(propertyInfo, conditional));
        
    }
    var newExpression = Expression.New(typeof(T).GetConstructor(new Type[0]));

    var expression = Expression.Lambda<Func<Dictionary<string, string>, T>>(
        Expression.Block(new[] { tmpVal },Expression.MemberInit(newExpression,args)),
        dic);

    return expression.Compile();
}
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

As an aside, this is an intimidating piece of code, but that is about bazillion time better than having to do this manually using IL manipulations.

What this code does is dynamically generate the following method:

(Dictionary<string,string> dic) => {
    string tmp;
    return new User
    {
        Name = dic.TryGetValue("Name", out tmp) ? tmp : default(string),
        Age = dic.TryGetValue("Age", out tmp) ? (int)Convert.ChangeType(tmp, typeof(int)) : default(int)
    };
}
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

This is pretty much the fastest way to do this, because this is how you would write it manually. And compiling the expression dynamically means that we don’t have to do this for each and every type we run into.

Categories: Blogs

Directives In AngularJS

C-Sharpcorner - Latest Articles - 20 hours 8 min ago
In this article, we will learn about Directives in AngularJS Application.
Categories: Communities

Door Lock By Keypad Using Arduino

C-Sharpcorner - Latest Articles - 20 hours 8 min ago
In this article, I will explain about the locking and unlocking door by keypad using Arduino.
Categories: Communities

Getting Started with ASP.NET MVC5

C-Sharpcorner - Latest Articles - 20 hours 8 min ago
In this article I am starting with the basics of ASP.Net MVC5 to help the beginner developer.
Categories: Communities

Delhi Chapter Meet February 7, 2016: Official Recap

C-Sharpcorner - Latest Articles - 20 hours 8 min ago
The C# Corner Delhi Chapter organized its monthly event, Delhi Chapter Meet at C# Corner, Noida on February 7, 2016.
Categories: Communities

Removing Potential Customer from Opportunity Form - Quick Tip

C-Sharpcorner - Latest Articles - 20 hours 8 min ago
This article is about removing potential customer lookup fields from opportunity forms.
Categories: Communities

South India Meet January 31, 2016: Official Recap

C-Sharpcorner - Latest Articles - 20 hours 8 min ago
The C# Corner Hyderabad Chapter organized its monthly event, South India Meet at Athithi Inn, Hyderabad on January 31, 2016.
Categories: Communities