Quantcast
Channel: ASP.NET Blog
Viewing all 7144 articles
Browse latest View live

Updates to ASP.NET 5 yeoman generators for beta 5

$
0
0

Hi everyone the blog post below is written by Peter Blazejewicz, who is a core contributor to the yeoman generators for ASP.NET 5. Peter took care of the majority of the updates for beta 5. I hope you enjoy, please leave your thoughts below in the comments.

Hi folks!

This week marks the release of ASP.NET 5 Beta5 and the related update to Yeoman generator for ASP.NET 5! There are many new things that are introduced to ASP.NET 5 generator with this update, both to client and server side. Here is the list of the most important additions:

  • New simple Web MVC application project template (without Membership and Authorization)
  • AngularJS 1.* templates
  • React template
  • TypeScript templates updates
  • CSS/Less/SCSS templates
  • Interface, Middleware, TagHelper templates

Nearly all existing templates have been updated, rewritten and revised during beta5 development. We have also expanded tests to cover nearly all content generation by generator too!.

Here's an animated gif showing yo aspnet in action on Mac OSX.

There are also changes in how templates are organized within the project, we use the same files structure now both in template content and in generated content, we unified files and subgenerators names and character-case. There is a simple pattern used during subgenerator implementation, which we hope will be easy to follow. As we changed templates organization, the futures changes and upgrades are expected to be easier to add and develop.

We hope this will ease contribution to the project - and we have already received PRs after beta5 update <3!

If you want to shape future of ASP.NET with us, help us by submitting issue or just discussing a topic and adding your own contribution to the project.

In case you missed them we have blogged on the ASP.NET 5 yo generators in the past.

Thanks!
Peter Blazejewicz


ASP.NET Community Standup - July 7, 2015

$
0
0

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 when a notice goes out on Scott Hanselman's Twitter feed with the exact link to each week's hangout.

This week's meeting is below:

Scott brought up a previous discussion: do we need the dot in this command-line:  "dnx . web"   -- referencing this GitHub issue:  https://github.com/aspnet/dnx/issues/1403

Damian explains that this is a breaking change that prevents Visual Studio from operating properly.  We have committed to preventing breaking changes at this point.  To accomplish this, Visual Studio and the ASP.NET framework are updated to be current version - 1 compatible.  If ASP.NET needs an update, it gets the update but is backwards compatible to support VS 2015.  In this way, VS 2015 can have a patch applied later to expose the new functionality in ASP.NET

Damian declared that there are changes in the RTM version of VS2015 to support a future version of the ASP.NET framework that has not yet been written or added to source control.

Scott shared that he now truly understands that the ASP.NET command-line interface is a programmatic interface that Visual Studio uses to integrate with ASP.NET

Damian followed up by declaring that the week of July 27th they plan to ship beta 6.  A new version of the Visual Studio ASP.NET tooling, called WTE, at the same time as beta 6.  The high-level schedule is still in progress, and should be agreed upon by all sides and published to GitHub as soon as a consensus is reached.

Community Links

 The META link… the team shared last weeks transcript.. So that you know how meta-cool this is: I'm including a screenshot of Jon showing a screenshot.  You're welcome Scott…

 

 

 

Q and A

The community requested that the hangout be announced 30-45 minutes ahead.  There are some small logistics issues with scheduling, but Scott promises to do his best

There was a request to share the HTML file templates on GitHub with the community.  Damian indicated that they actually ARE on GitHub in a private repository, and there is a number of eyes on the templates to ensure that they help deliver a good experience for new developers to ASP.NET.

Scott followed-up with a request about possibly using the Yeoman templates that have been developed in place of the templates included in Visual Studio.  Something could happen with that, but Damian does not think that will happen as Microsoft wants to deliver curated content as the starter experience.  Scott agreed, and indicated that nothing prevents a developer from using the Yeoman generators with Visual Studio as a command-line based 'File -> New' option.

As a follow-up to the discussion about Raspberry Pi, Damian recommended that you buy a Raspberry Pi 2 from Element 14.  Element 14 is the official distributor of Raspberry Pi in the United States, for those living outside of the US, consult the Raspberry Pi website for a distributor near you.

A question about performance was raised: why does it take so long between MVC controller code modification and first-byte in browser?  Damian described the compilation process to deliver that first byte, and declared a 1 second target performance the team is working towards. 

Why does the DNX store its resources in the %USERPROFILE%/.dnx folder?  Damian and Jon had a discussion about this, and it’s a design by the ASP.NET team to ensure that the dnx resources are stored in the same place no matter the operating system in use.  In Unix / Linux based environments, a user's home folder holds important application specific content in folders that are prefixed with a dot and then hidden.  This convention was carried over to all operating systems by ASP.NET

A question up about possibly forcing a refresh of a browser viewing a website being debugged when a compile completes in Visual Studio.  After some discussion, the guys acknowledged it as a good idea and will discuss providing similar functionality in a future update.

A viewer asked about pressure on the community to adapt the next versions of dnx by discontinuing support for earlier versions.  Damian assured that all versions of .NET since v4 have been in-place updates, replacing previous versions on disk.  He went on to explain that the servicing base-line was reset to .NET 4.5.1 in 2014 and this means that service updates to .NET are only available to .NET 4.5.1 and later.  There is no pressure on the community to upgrade to the latest version of dnx and ASP.NET 5.

Scott followed-up by describing that ASP.NET 4.6 is alive and well and is production ready on July 20th with the Visual Studio launch.  Scott admitted that his blog still runs ASP.NET 2, and he has been updating it with Visual Studio 2015 and Roslyn tools to improve performance and stability.  With the new updates, Scott can now run his website on an Apple Watch.  Okay, that’s a stretch…

Regarding performance testing, there are team members working on implementing some experimental changes in the kestrel web server.  Damian says that they've run into a problem where they have saturated the gigabit NIC on the test machines and they need to upgrade the test hardware to 10 gigabit and run the tests again.

With a dramatic zoom-out, the meeting concluded. Watch Scott's twitter feed next week, on July 14th around 18:00 UTC for the link to the next ASP.NET community hangout.

A Glimpse into the future of Web Development Tools

$
0
0

Glimpse LogoThere’s some exciting news for the ASP.NET community this week on the Visual Studio blog that we wanted to take a moment to point out. Nik Molnar and Anthony van der Hoorn, the creators of Glimpse, have joined Microsoft on the Visual Studio team!

 

The ASP.NET team have been fans of Glimpse since we first saw it at the Mix 11 Open Source Fest. It’s a great open source debugging and diagnostics tool. Glimpse is similar to the F12 tools built into browsers, but instead it provides insights into server side concerns like route matching, view rendering and database queries. If you’d like to learn more about Glimpse, check out our own Brady Gaster’s interview with the guys on Web Camp TV.

Now that Nik and Anthony are at Microsoft, they will continue their work on Glimpse and web tooling. We’re excited to have them join our ranks, look forward to working directly with them and are excited to see what’s to come.

ASP.NET Community Standup - July 14, 2015

$
0
0

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 when a notice goes out on Scott Hanselman's Twitter feed with the exact link to each week's hangout.

This week's meeting is below:

Today's show featured guests and new Microsoft employees Nik Molnar and Anthony van der Hoorn

First big announcement of the show: Nik and Anthony's open source project Glimpse is now sponsored by Microsoft.  Nik and Anthony will continue to build and work on Glimpse as part of their work on the cross-platform and tools group.  More details about their relationship between Glimpse and Visual Studio can be found on the Visual Studio blog.

Since Nik is a Program Manager and Anthony is a Developer, Scott pointed out that they will get to arm-wrestle a lot.

Scott asked how Glimpse will impact ASP.NET 5.  The response from Anthony indicated that they have attempted to port Glimpse v1 to ASP.NET 5 and found it to be very complex and requiring a complete re-write, but a re-write that was much simpler to implement thanks to the new framework.

At this point, Scott hit an interesting technical problem with the video meetup and fun ensued.  We discovered how many program managers are needed to run a video meetup, and the answer is at least four.

Once Scott re-entered the meeting, Damian revealed the next announcement: the release schedule for ASP.NET 5 is locked in.  Mid-November is the target date for ASP.NET 5 RC with a go-live license.  Scott wants to be able to go-live with a new web site on a Linux machine on the American Thanksgiving holiday at the end of November.  Damian confirmed that will be a valid scenario supported at that time.

Scott followed-up by asking: Will Glimpse work at that time with ASP.NET 5?  Anthony responded that the team is following along with the ASP.NET 5 development and will have something available for use at the time of the RC.

Jon asked Anthony and Nik: What is the 'up-and-running' story for Glimpse in ASP.NET 5?  Anthony explained that the changing versions of ASP.NET are introducing complexities for the team to analyze and attempt to maintain compatibility with.  They don't yet have an answer and are working through this design with the ASP.NET team.

Damian next discussed performance, as we love to hear about in these discussions.  Damian recounted a twitter discussion with Kelly Sommers about kestrel performance on Linux.  The ASP.NET team has not focused on performance of the  kestrel web server on Linux and after replicating Kelly's configuration on the team's performance testing rig, they have identified a number of performance issues and started to remedy them.  New hardware has arrived to help test and diagnose these issues, and the team is actively working on improving kestrel web server performance on Linux.

Anthony asked Damian if the servers were in the building, and Damian pointed just outside the conference room door at the hardware.  Scott followed up by asking if we could go on a tour in a future standup to show the performance lab.  Damian agreed and indicated that some followers on Twitter asked if the performance testing could be broadcast with Twitch or some mobile camera.  The guys are going to plan for a tour in a future standup.

Scott wrapped by asking if the standup could be held next week at the same time as this week: 15:00UTC.  That looks like the time we will start on July 21st.

Links of the week:

  • The announcement blog post introducing Nik and Anthony
  • Reverse Package Search from Glenn Condron  http://packagesearch.azurewebsites.net
    • Damian chimed in that this site was built to help locate NuGet packages that provide features from the .NET 4.x base-class-library.  In particular the reflection APIs have changed and you will want to use this resource for help.

Summary

Damian hopes to have the roadmap published on the ASP.NET GitHub Home repository.  Tune in next week for official details about the planned release dates and features.


New version of ASP.NET Merge Tool

$
0
0

The ASP.NET Merge tool (Aspnet_merge.exe) enables you to combine and manage the assemblies that are created by the ASP.NET compilation tool (Aspnet_compiler.exe). It was built on top of a Microsoft Research project, ILMerge, through which Aspnet_merge.exe does IL code merge.

 

What problem does this new version fix?

The first version of this tool was released through .Net framework 2.0 SDK, since then we haven’t update the ILMerge part much. As .Net evolved, IL becomes more and more complex and the old ILMerge can’t work correctly in some corner cases.  This leads to a CLR failure to load the resulting merged dlls. In this release, we took the latest version of ILMerge into Aspnet_merge which fixes those issues.

 

How to use the new version of the ASP.NET Merge tool? 

1. Manage NuGet packages in your project and search for Microsoft.Aspnet.Merge. Please check the Include prerelease box, because this is a beta release.

2. Right click on your web application project and click on Publish (or Publish Web Site in web site project)  to create a publish file for your project.

3. Click File Publish Options in Settings, you should see precompile option. Then click on Configure and you will find several merge options. You can select one of them based on your requirement. Below are the explanations of each option.

  • Do not merge– just use aspnet_compiler.exe to precompile the whole web application without merging assemblies.
  • Do not merge.  Create a separate assembly for each page and control - This uses the -fixednames option on aspnet_compiler.exe.  It does not merge the assemblies, but creates a separate one with a consistent name (based on the path) for each file.
  • Merge all outputs to a single assembly - This is the same as the -o option on aspnet_merge.  It will precompile your site and put it all entirely in one assembly.
  • Merge each individual folder to its own assembly - This is the same as the -prefix option on aspnet_merge.  It will precompile each directory separately into <prefix>.<directoryName>.dll.
  • Merge all pages and control outputs to a single assembly - This is the same as the -w option on aspnet_merge.exe.  It will compile all of the UI pages (.aspx, .ascx, .master, etc...) into a single assembly.

 

 

Feedback

If you find any issue or want to ask a question regarding what’s discussed in this article, please leave a comment below, or use the Contact Owners Form on the NuGet package details.



Announcing ASP.NET 4.6 and ASP.NET 5 beta 5 in Visual Studio 2015 Release

$
0
0

Long time readers of this blog or followers of the ASP.NET Community Standup know that this day was coming, and we have a released version of ASP.NET 4.6 framework and tools with Visual Studio 2015.  Not only are we shipping ASP.NET 4.6, but we are also including with Visual Studio 2015 a bundle of ASP.NET 5 beta 5 runtime tools and libraries.  There’s a lot of
great new features in ASP.NET 4.6 and ASP.NET 5 that you need to know about.  Let’s take a closer look at some of the bigger features in this release of Visual Studio.

ASP.NET 4.6 – More of the ASP.NET you know and enjoy

We are delivering updates to the existing ASP.NET 4.5.2 tools and frameworks that run on Windows and within Internet Information Server.  The configuration and interaction with the operating system and web server that you have known has not changed, and you can continue to build with Web Forms, MVC, Web Pages Web API, and SignalR.  In fact, the new
versions of these frameworks are as follows:

  • ASP.NET Web Forms 4.6
  • ASP.NET MVC 5.2.3
  • ASP.NET Web Pages 3.2.3
  • ASP.NET Web API 5.2.3
  • ASP.NET SignalR 2.1.2

You can find a detailed description of the issues fixed in these frameworks in our announcement blog post about their release.  Lets take a look at some code samples

Web Forms Model Binding now supports Task returning methods

Model binding in web forms is a newer feature and has always run synchronously, even when the page was marked with an async=”true” directive.  With this release, you can add async keywords and return Task objects to your methods.  Now you won’t have to wait quite as long for that database insert or update when posting back to a page.

More examples about async model binding in Web Forms can be found on our blog post.

Enabling the .NET Compiler Platform

New language features delivered in the updated .NET Compiler Platform (“Roslyn”) are available throughout ASP.NET.  You can use these advanced features on your web forms markup, razor templates, and in your code-behind files. Web Forms projects now include the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package by default.  This allows the web forms projects to pre-compiler and deliver your web forms projects significantly faster.

HTTP/2 Support

In Windows 10 and ASP.NET 4.6 there is now support for HTTP/2, the next major update to the web’s protocol.  According to the HTTP working group, this is not a rewrite of the protocol and that all methods, status codes, and semantics remain the same. The key differences between HTTP/2 and HTTP/1.x are:

  • Binary transmission instead of text
  • Fully multiplexed instead of ordered and blocking – this means your images, stylesheets, scripts, and other static resources are all loaded concurrently
  • One connection to the server can be used to promote parallel loading of resources
  • Header compression is now used to reduce overhead
  • Servers can now “push” responses proactively into client caches

Check out this video from Program Manager Pranav Rastogi on Channel 9 where he demonstrates the advantage of HTTP/2 in ASP.NET 4.6

Identity and Authentication Updates

The ASP.NET 4.6 templates now use Open Id Connect middleware to authenticate to Azure Active Directory (Azure AD) which makes the programming model to authenticate with Azure AD much easier.  Additionally, when starting a new project and you choose the ‘Individual User Accounts’ option then the templates will provide sample code for two-factor authentication and social logins with ASP.NET Identity 2.2.1.

In App_Start\IdentityConfig.cs you can find a sample two-factor authentication configured as follows:

The EmailService and SmsService can be configured to actually transmit messages with your own choice of email and SMS providers.  In this case, they do nothing and users are allowed to access the application normally.

Social logins can be configured using the sample code hiding in the comments at the bottom of AppStart\Startup.Auth.cs

Simply uncomment the providers you wish to use, register as a developer with an application on their sites and enter the authentication information those providers give your application into this code.

More details can be found in the ASP.NET Identity 2.2.1 announcement blog post.

JSON Editor Improvements

The JSON editor was significantly updated in this release with new features like:

  • JSON Schema validation – we now support the JSON Schema draft v4 specification
  • Intellisense for bower.json and package.json configuration files used by the bower and npm package managers
  • Duplicate property validation
  • Support for SchemaStore.org – an open source collection of useful JSON Schema files.  Any JSON file that has a schema associated on SchemaStore.org will automatically get intellisense and validation support.

 

Figure 1 - JSON Intellisense with SchemaStore.org support

Figure 2 - Bower Package Intellisense

You can find video of Program Manager Mads Kristensen talking about the cool new editor features on Channel 9’s Web Camps:

HTML Editor Improvements

The HTML editor has seen a number of additions to make it the modern text editor tool that web developers prefer.  We’ve added:

  • Better client template formatting with regards to the double-curly brace syntax.  {{…}}   This ensures that the inner content is not treated as HTML and being marked as invalid by the editor.  This is a great benefit for developers using Angular, Handlebars, Mustache, and other double-curly brace templates.
  • Improvements to support web components and other custom elements.  Custom elements will not be marked as invalid and the editor support the<link rel=”import”> tag for web components.  The editor will provide intellisense for those components that it can find with an imported definition.
  • Intellisense for angular directives and attributes.  There are icons that will appear in the intellisense box to indicate that these are angular supporting options
  • Bootstrap CSS class intellisense with icons to show that the class came from a bootstrap library

 

Figure 3 - Bootstrap CSS Framework Intellisense

JavaScript editor improvements

We’ve added the following features to our JavaScript editor:

  • AngularJS support with intellisense for angular controllers, services, factories, directives, and animations
  • New JavaScript language features (from the EcmaScript 6 version of JavaScript) including classes, arrow functions, and template strings
  • New Navigation bar to help in moving between major elements in your script
  • Documentation comments written in JSDoc format are shown when using intellisense
  • Object literal intellisense showing suggestions when passing an object literal to functions documented using JSDoc

 

Figure 4 - JavaScript Editor with JSDoc and Intellisense support

Support for JSX (React.JS)

The most requested feature in the text editor was for support of the .jsx extension.  Now you can get intellisense, formatting and validation in the editor as you type.  With the collaboration of the Facebook team that is responsible for the react.js library, we believe we’ve delivered a great experience for react.js developers.

 

Figure 5 - React.JS Syntax Highlighting Support

Azure Web Apps Availability

With the brand-new release of ASP.NET 4.6, the Azure Web Apps service is still being prepared and tested for this important update.  Once we have confirmed that Azure Web Apps can host an ASP.NET 4.6 application with the same high level of performance and fidelity that you expect from Microsoft Azure, we will announce compatibility of the service.  Our operations team is working diligently and we will update you on the Microsoft Azure blog in the near future.

ASP.NET 5 beta 5 Support

ASP.NET 5 is a lean and composable .NET stack for building modern web applications for both cloud and on-premises servers.  This re-write of ASP.NET was started in order to provide an improved, modern web framework that could be run cross-platform and updated as quickly as the web changes.

ASP.NET 5 includes the following features:

  • New light-weight request pipeline
  • Run on IIS, or self-hosted in your own process
  • Built on new .NET Execution Environment (DNX) that can run on the full .NET Framework or on .NET Core, a new cloud-optimized runtime that supports true side-by-side versioning
  • Runs cross-platform on Windows, Mac, and Linux
  • Everything is a package delivered with NuGet, even the runtime itself
  • Comes with ASP.NET MVC 6 - a unified Web framework for Web UI and Web APIs
  • Environment-based configuration for a seamless transition to the cloud
  • Dependency injection out-of-the-box
  • New Visual Studio project system and high productivity tooling experience
  • All open source on GitHub through the .NET Foundation

Visual Studio 2015 includes the ASP.NET 5 beta5 runtime packages. These packages are still in preview and are not recommended for use in production. You can find all the details on the specific enhancements added and issues fixed in the published release notes on GitHub.

The ASP.NET 5 team has published a roadmap to their public release on GitHub.  Be sure to check that out if you are interested in when you can publish an application to production.

You can read more about the new ASP.NET 5 beta 5 release on their announcement blog post.  Our ongoing series of announcements and updates with each beta release of ASP.NET 5 goes into details with samples for these items.  Follow the ASP.NET 5 tag on this blog to keep up with the changes.

You can also catch up with the weekly changes in the advancements of ASP.NET 5 with the Community Standup videos on YouTube and the transcripts hosted on this blog. 

Summary

We are very happy with this latest release of ASP.NET tools for developers in Visual Studio 2015. Our teams are excited for you to start working with these tools and build something amazing.  We look forward to your feedback, experiences, blog posts, and comments about the new tools.  If you haven’t already, go to VisualStudio.com and download a copy of Visual Studio 2015 to get started today.

ASP.NET Community Standup - July 21, 2015

$
0
0

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 when a notice goes out on Scott Hanselman's Twitter feed with the exact link to each week's hangout.

The team has shared their scheduled roadmap of features and deliverables for ASP.NET 5 on GitHub. 

This week's meeting is below:

In this very special edition of ASP.NET Community Standup, Scott and Damian started with a quick tour of the "ASP.NET Smurf Lab" that is being used to help performance test the new ASP.NET web servers as they are being developed.   The specs for the machines in the lab are available online.

This is a real performance lab, and not some Hollywood conjured setup with refrigerator sized computers with lots of blinky lights.  The goal is to test out a series of different implementations to get some baseline performance numbers and compare them to the TestEmpowerment performance results  In Damian's screen, he's connecting with the SSL client PuTTY to one of the Ubuntu machines to generate network load with the open-source wrk tool.

More details and information about the progress of the benchmarks and performance tuning effort can be found in the ASP.NET Benchmarks repository on GitHub.

Damian showed us a test based on a pull request by Ben Adams using Windows 8 registered IO APIs (RIO), a layer on top of WinSock that help to improve throughput.  With a basic implementation that only scans for 2 carriage returns, which signals the end of the network Damian ran 450 connections with 32 threads on the client and 150 requests and delivered 7.7 million requests per second against this prototype service.   By comparison, a service called TcpEcho which is built on top of libuv is handling 2.4M requests/sec but saturates the CPU.

Damian pointed out that the team is being extremely careful about how logic will be inserted into the new service so that it does not stall processing and significantly impact performance.  This is why the team is using this test lab and these results are influencing the development of the kestrel web server.

Current Performance Results for various Web Frameworks

These benchmarks from TechEmpower are doing a standard set of work to respond to a request, and the prototype services Damian showed are not fully implemented to compete against these numbers.  Once the prototype ASP.NET HTTP service is fully implemented, we will have a proper number to compare against these benchmarks 

Q & A

Question: Are there any gotchas with using VS 2015 RTM and the development branches of ASP.NET 5?

There is one issue with the naming of an object causing a problem with Visual Studio that will be fixed in next week's release.

Question: With the roadmap now published, what is in 4.6 that will not be in ASP.NET 5?

The HTTP/2 push/promise API is not going to make it in ASP.NET 5, but is available in 4.6.  The other HTTP/2 features like header compression and request multiplexing are in the ASP.NET 5 featureset when used with Windows 10.

Question: Can you do an in-place upgrade of Visual Studio 2015 from RC to the RTM bits that were released this week?

Yes, the team went through this test prior to Visual Studio 2015 being released and they can confirm that it works great.

Question: Any guidance for SignalR usage in Asp.net 5?

The roadmap dictates that SignalR and ASP.NET Webpages will not make the RTM release, but are scheduled to be available in Q3 2016.  There is a SignalR 3 beta5 package that supports some of the interfaces with the existing JavaScript clients for SignalR 2.  There are no guarantees that this beta will work through the end of the ASP.NET 5 development schedule.

Scott pointed out that Web Pages and SignalR are open source, and developers could contribute to those projects.  Damian furthered that SignalR could be updated by developers in the community with some Microsoft guidance but that Web Pages will change significantly and it may not be a good target for community contributions.

Summary

The team wrapped up this performance testing-focused discussion and demonstration with an open-ended question: do you enjoy these insights into the development and testing process?  Sound off in the comments below.  Next week the team will be meeting around 16:00 UTC on July 28th.

Announcing Availability of ASP.NET 5 beta 6

$
0
0

It feels like we just did this… we just announced an ASP.NET release, and here comes another one.  The development team has been hard at work right through the release of Visual Studio 2015 to deliver an updated set of packages and tools for you to use with ASP.NET 5.  This release, labeled ASP.NET 5 beta 6 contains a handful of new features in the framework and packages.  Let’s take a look at how we can get started adding ASP.NET 5 Beta 6 to our Visual Studio 2015 install.

Installation

For the first time in the ASP.NET 5 beta cycle, we are publishing a new version of the Visual Studio web development tools with the updated framework.  Previously, Visual Studio users would need to go through some significant changes in order to attempt to use the latest beta versions of ASP.NET 5 with their editors.  Starting with this version, you can go to the download center and get directions on how to update Visual Studio and any other editor you may be using.

Framework Updates

There are a number of changes and updates to how you can interact with the ASP.NET framework.  None of these changes are breaking, and add significant functionality that you can use.

SQL Server Distributed Cache

The new Microsoft.Framework.Caching.SqlServer package will allow you to use SQL Server as your cache store in ASP.NET 5 applications.  This enhancement allows you to cache your data when running ASP.NET in a web-farm scenario and the in-memory cache is no longer appropriate.  You can configure your SQL Server Cache with the following steps in your project folder:

  1. Run dnu commands install Microsoft.Framework.Caching.SqlConfig to add a sqlservercache command to your workstation in the %userprofile%\.dnx\bin folder.
  2. Run sqlservercache create <connection to db> <schemaname> <tablename> to configure the cache on the database server
  3. Add a reference in your project to the Microsoft.Framework.Caching.SqlServer package
  4. Register the cache with the ASP.NET dependency injection in the ConfigureServices method:
  1. Add parameters to your objects where you would like an IDistributedCache injected.

You can read the official announcement about this library on the ASP.NET Announcement Repository.

Strong name support for assemblies

You can now mark assemblies in your build process for strong naming.  The project.json file now has configuration options that can be set at various levels in the file for individual build configurations or framework version.  Define the strong naming properties with a compilationOptions element that looks like:

"compilationOptions": {

"strongName": true,
"delaySign": true,
"keyFile": "MySecretKeyFile.snk"

}

Place this section on the root of your project.json file to force all project configurations and frameworks to strong-name or you can place it inside an individual configuration element or framework element.  For example, to force strong-naming for release configurations, I can have this configuration section in my project.json file:

Trailing Slash support

A feature from previous MVC framework versions that had not made it over the MVC 6 yet is the ability to configure routes to append a trailing slash.  In MVC 6 this is a configuration option on the Microsoft.AspNet.Routing.RouteOptions class.  To enable this feature, simply configure add the following RouteOptions configuration in the ConfigureServices method in the Startup class:

services.Configure<RouteOptions>(opts =>
{
    opts.AppendTrailingSlash = true;
});

Response Buffering and Caching now enabled for WebListener

With server applications it is important that we use all of the resources available to us in order to deliver great performance. When running ASP>NET 5 on Windows and IIS you get efficient response buffering and caching using the native response caching in HTTP.SYS. Starting with this beta you get the same support when running on WebListener.  No configuration changes are needed to enable this performance boost.  None.  Nada.  You get more performance for free whenever cache response headers are used, and that’s a good thing.

MVC and WebAPI Packages – Less is Better!

We know that a lot of ASP.NET developers are enjoying the MVC 6 implementation with WebAPI.  It was a natural match that works really well together and has delivered some great experiences from the early feedback we are hearing.  We have also heard from some developers who really like WebAPI and don’t want to have their application waste time loading other resources that WebAPI doesn’t use like Razor or TagHelpers.

Starting with beta 6, you can now consume a smaller subset of the MVC packages to allow you to work with WebAPI functionality and exclude other dependencies that you don’t need for your implementation.  Typically when you work with MVC 6, you only need to include one package: Microsoft.AspNet.Mvc and you get all of the references you need through transient dependencies.  You may also call this feature “indirect package references”, as this feature of the package manager allows all of the dependent packages that make up MVC and WebAPI to be included in your project with no extra code or configuration.

The update in this beta 6 version allows you to specify a subset of those indirect package references.  In the scenario described above, where a WebAPI developer doesn’t want all of the Razor and TagHelper features, they can use a project.json configuration file with this subset of dependencies to deliver a WebAPI-only application:

Summary

This is an incremental release of the ASP.NET 5 frameworks and we hope that you download a copy of the ASP.NET 5 tools and framework and try it out.  We have a long road still ahead of us, and we hope you follow our ASP.NET 5 roadmap and provide feedback on the features you like and don’t like.  You can start by replying to this post and telling us what you think of these new features that were added.  After that, stop by the next ASP.NET Community Standup on Tuesday and you can ask the ASP.NET 5 Program Managers any follow-up questions you may have.


Unit testing with DNX (ASP.NET 5) projects

$
0
0

One common question that I get is “How do I unit test my ASP.NET 5 (DNX) projects?” The biggest reason for the question is because we don’t have a good starting point (File->New Project) for unit testing. I’m happy to say that today we’ve solved this problem. We now have templates for both Visual Studio and command line users. I’ll explain how you can get, and use, the templates here.

Note: this blog post is based on ASP.NET 5 beta6, if you don’t already have that installed please install it. More info at http://blogs.msdn.com/b/webdev/archive/2015/07/27/announcing-availability-of-asp-net-5-beta-6.aspx.

Adding an xUnit project using SideWaffle

If you are using Visual Studio and want to create a DNX unit test project, to get started first download a fresh copy of SideWaffle (version 1.19 or higher for xUnit). After you install SideWaffle you’ll have a new xUnit project template. Let’s walk through it. To get started open your existing solution using Visual Studio 2015 that has your DNX projects. From there go to File->New Project and navigate to the web node. From there you should see the following list of available templates.

image

In the image above you’ll see a new xUnit test project. Use that to create your test project. When you use that template here is what you get in Visual Studio.

image

The content for Class1.cs and project.json are shown below.

project.json

{"version": "1.0.0-*","description": "UnitTestProject1 test project","authors": [ "sayedha" ],"tags": [ "" ],"projectUrl": "","licenseUrl": "","dependencies": {"xunit": "2.1.0-beta4-build3109","xunit.runner.dnx": "2.1.0-beta4-build134"
  },"commands": {"test": "xunit.runner.dnx"
  },"frameworks" : {"dnx451": { },"dnxcore50" : {"dependencies": {"Microsoft.CSharp": "4.0.0-beta-22816","System.Collections": "4.0.10-beta-22816","System.Linq": "4.0.0-beta-22816","System.Threading": "4.0.10-beta-22816"
      }
    }
  }
}

Class1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;

namespace UnitTestProject1
{
    // This project can output the Class library as a NuGet Package.
    // To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build".
    public class Class1
    {

        [Fact]
        public void UniTest1()
        {
            Assert.True(true);
        }
    }
}

At this point in Visual Studio you can build your solution and then open Test Explorer to see the test cases as shown in the screenshot below.

image

That’s it, from here you should be able to create, run and debug xUnit test cases in Visual Studio 2015. Now let’s move on for the command line users.

Adding an xUnit project using yeoman for command line users

If you are not using Visual Studio that’s OK, we’ve got you covered. We have previously blogged about the yo aspnet yeoman generator, see these posts for more details.

You can get started with yo aspnet pretty easily, see the instructions in the yo aspnet readme. After you have yo aspnet installed the latest version of yo aspnet when you invoke yo aspnet form the command line you should see the following.

image

In the screenshot above (running on my Mac) you can see that we now have a Unit test project. Select that project type, hit enter and give your project a new name. After that a new project is added with the same contents as above. From there you can cd into the directory and run dnu restore to restore the NuGet packages and then dnx . test to run all the test cases. See the screenshot below which shows this.

image

In the screenshot above you can see that one test case was executed and that it passed.

 

That is pretty much all that you need to get started with creating xUnit test cases for DNX projects. In the future we are hoping to add unit testing templates into Visual Studio itself (i.e. w/o SideWaffle). Please let me know if you try it in the comments below.

 

Sayed Ibrahim Hashimi – @SayedIHashimi

ASP.NET Community Standup - August 18, 2015

$
0
0

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:

Today's meeting featured a visit from our boss, Scott Hunter with some important information about education for the ASP.NET 5 tools.

Damian started the conversation by announcing that ASP.NET 5 beta 8 coding is starting this week and beta 7 verification should be completed next week with a public release shortly after.  The beta 8 release is focused on polish and not so much on new features.  Look for bug fixes, engineering debt to be addressed, stress testing improvements, performance improvements, and a general improvement in the ASP.NET 5 experience. 

The beta 7 release should be in the first week of September with a big push on cross-platform updates including new .NET core drops for Linux, Mac, and Windows.  There is a significant update for dnvm that will allow installing runtimes for alternate platforms besides the platform you are developing on.  The .NET Core update includes networking and HttpClient features that will allow cross-platform networking with ASP.NET.  This also means that dnu commands on Mac and Linux will; run without requiring the mono runtime.

Scott Hunter next talked about the need for education around the new ASP.NET and shared some success stories about workshops that were delivered at conferences earlier in 2015.  He requested some feedback from our ASP.NET community:  do you prefer the eight hour paid workshop format at conferences that walks through developing a real web application or the one hour breakout session that discusses features?  Please reply in the discussion area below with your thoughts.

Scott also shared the current travel schedule for the ASP.NET program managers.  (editor's note: I've added some other entries to this list that Scott did not have on his initial slide)

 

DateEventLocationSpeakers
September 14DevConnectionsLas VegasJeff Fritz
September 24Reaktor BreakpointHelsinkiScott Hanselman
September 26WebNextConfMilan, ItalyScott Hanselman
October 10Philly Code CampPhiladelphia, PAJeff Fritz
October 15DevIntersection / AngleBracketsAmstredamScott Hanselman, Scott Hunter
October 19.NET Developer DaysWarsawScott Hanselman, Scott Hunter
October 21TechDays SwedenStockholmScott Hanselman, Scott Hunter
October 26Trondheim Developer ConferenceTrondheim, NorwayScott Hanselman

In the 2016 timeframe, as we close in on the RTM date of ASP.NET 5, look for more postings about in-person opportunities to work with the ASP.NET team with workshops and sessions at conferences near you.  If there is an event in 2016 that you want to see us visit, reply in the discussion are below with the event information and contact information and we'll reach out to discuss how we can work with your event.

If you can't make it to some of these events, look for three new Microsoft Virtual Academy courses to be released around ASP.NET 5 topics.  There will be an introduction course, an advanced course, and then a cross-platform development course.  These courses will be released over the next few months, keep an eye on this blog and on the ASP.NET standup for more information as they are released.

Links of the Week:

As a follow-up comment to Sayed's blog post, Damian indicated that The unit test project is coming back in the One ASP.NET dialog in beta 8 or RC.  As API churn goes down, this feature will be re-enabled.

Q and A

Question: Now that .NET Core 5 is split into assemblies, how do I find what I want?
Use the packagesearch.azurewebsites.net site to help search for the APIs you are looking for.  A Visual Studio feature is being built that will provide this feature as a lightbulb on the left gutter.  


Question: A header is added for server in the response to a client. What is the best way to kill the header? Can an action filter solve this?
Its not added by ASP.NET, the server adds that and you need to kill it there.  On IIS you should be able to modify configuration to handle it.  Kestrel adds the entry in the headers collection and it can be modified since Kestrel is managed code in the ASP.NET pipeline.  Damian recommends attempting to do it with middleware on ASP.NET 5, or modules in older ASP.NET versions.

Question: Can the team visit South Africa?
We'll plan to visit next year

Question: Any drawbacks on Workshops vs. talks?
Workshops are not recorded, as they are paid for separately, and much longer.  At big commercial shows, one hour breakout sessions are recorded or streamed.  Our Workshops will also be available on Microsoft Virtual Academy.  Additionally, look for the ASP.NET CodeShow coming soon with Scott Hanselman and Glenn Condron.

Question: Any word on Auth Server?
The ASP.NET Team is working with Auth Server so that it is ready in November with the ASP.NET 5 RC.  We are still working on some details around if it will be included in the box, but it will probably be the recommended security solution

Question: Do we have a performance testing update this week?
Kestrel hit 164k requests/sec and the team is working towards about five times that performance, but may not hit that for v1.  This performance will improve as the product matures and there is lots of work on performance across MVC, not just Kestrel


Question: When can I create Azure cloud projects integrated with vNext projects?
Web and Worker roles are to be determined wIth the new forms of compute being offered, the team is trying to decide if we should invest in the v1 or new v2 version for this.  We're leaning towards to v2 but need feedback, please give us yours in the discussion area below.

Question: Entity Framework does not seem as stable as MVC
EF7 is shipping with ASP.NET 5.  There are some known takebacks that are documented on their site and you should log issues on GitHub if you find any.  There is no plan to go back to EF6, it is not compatible with .NET Core or Mac and Linux.

Question: Is any work being done on obfuscation?
No... no work on IL obfuscation has been started by Microsoft, however others could contribute this feature.

Question: It would be interesting to review the business and development process by which ASP.NET re-write was approached.
Neat idea... maybe something we can discuss in 2016.

Summary

The team is looking for a lot of feedback on a number of topics.  Reply in the discussion area below and we'll follow up with you.  Look for the next standup on Tuesday September 8th at 17:00 UTC on live.asp.net

Announcing Availability of ASP.NET 5 Beta7

$
0
0

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.NET 5 beta7.

Installation

Note: To use ASP.NET 5 beta7 with Visual Studio 2015, you will need to download and install the beta7 version (14.0.60831.0) of ASP.NET and Web Tools 2015.

On Windows download and install the latest ASP.NET and Web Tools updates for Visual Studio 2015.

For Mac and Linux follow the instructions in our documentation.

Getting started with the new .NET Execution Environment (DNX) for .NET Core on Mac/Linux

The .NET Execution Environment (DNX) provides a consistent way to build and run cross-platform .NET projects and is the basis for ASP.NET 5. In previous preview releases we provided DNXs for the full .NET Framework, Mono and .NET Core. The .NET Core support was initially limited to Windows, but in this release DNX support for .NET Core is now available in a limited fashion for both Mac and Linux. You can find instructions for installing DNX for .NET Core on Mac and Linux in our documentation.

What else is new?

In addition to the new support in DNX for cross-platform .NET Core this release is loaded with new features and improvements. For a full list of what is new in this release please refer to the beta7 release notes. Below is summary of some of the highlights:

.NET Execution Environment (DNX)

Drop the dot. Use `dnx web` instead of `dnx . web`

DNX now by default looks in the current folder for a project to run. Instead of `dnx . web` just type `dnx web`.  To explicitly specify the path to the DNX project to run you can use the --project option.

Improved `dnu restore` output

You can now easily see which package sources were used after doing a `dnu restore`. You can even see which NuGet.Config files were used to determine the set of package sources used:

Better handling of for incompatible package dependencies

You now get useful errors when trying to consume packages from a DNX based project that do not support the frameworks targeted by the project:

Specify which .NET Framework version to run

When running on the full .NET Framework you can now use the new --framework switch with DNX to specify which .NET Framework version to use (ex. dnx451, dnx452, dnx46).

Support for app.config when running on the full .NET Framework

When running on the full .NET Framework you can now use System.Configuration to access configuration data in app.config from a DNX based console application. Simply put your XML configuration file next to your project.json file.

Specify the OS when installing DNX using DNVM

You can now use the -os flag to specify the OS when installing a DNX using DNVM. For example, you can install a DNX for Linux on Windows and then publish an app with a Linux runtime from a Windows machine.

More details from `dnvm list`

The new -detailed flag to `dnvm list` now shows the location for each installed DNX.

Testing

New unit testing templates

You can now quickly get started with unit testing for DNX based projects using the new xUnit Test Project from SideWaffle. You can also generate a unit testing project from the command-line using the YeomanASP.NET generators. Check out Sayed Hashimi’s blog post on Unit testing with DNX (ASP.NET 5) projects for all the details.

Support for discovering async tests

Previously you could only write and discover synchronous unit tests for DNX projects. You can now write and discover asynchronous tests.

Kestrel

Chunked responses

Kestrel now supports writing chunked responses automatically when no content length is specified for the response.

Write behind buffering

Kestrel now uses write-behind buffering to more efficiently write responses to the network.

MVC/Razor

Razor comment blocks no longer introduce unnecessary whitespace

In previous versions a Razor comment block would leave unnecessary white space in your rendered views. Razor is now smart about removing this whitespace when the entire line consists of a Razor block. Your rendered views now look cleaner and consume less bandwidth.

ViewComponentResult

The new ViewComponentResult in MVC makes it easy to return the result of a ViewComponent from an action. This allows you to easily expose the logic of a ViewComponent as a standalone endpoint.

UrlResolutionTagHelper

In previous releases of MVC handling of URLs containing a ~ to refer to the web root of the application was handled directly in Razor. Any instances of ~ in your views were handled this way even if the value wasn’t a URI.

Support for ~ is now moved out of Razor into the new UrlResolutionTagHelper, which restricts handling of ~ to only src and href attributes of well-known HTML elements. The UrlResolutionTagHelper is added by default, but can be removed using the @removeTagHelper directive. Hurrah for

Tag helpers

Restrict child elements using RestrictChildrenAttribute

Sometime you have multiple tag helpers that work in conjunction with each other where one tag helper is the parent of another (ex. rows/columns in a grid). You can now declare that a tag helper expects only certain child elements using the RestrictChildrenAttribute. The parser will throw an error if other elements are found and this metadata can be used by tooling to provide a better editing experience (ex. red squiggles for invalid child elements).

Support for elements without end tags

You can now use the TagStructure.WithoutEndTag option in the TargetElementAttribute to specify that a tag helper should apply to an element even when it has no end tag (includes self-closing tags). You can detect the form of the element using the updated TagMode property on TagHelperOutput.

Re-execute child content

You can now use tag helpers to have template-like behavior by re-executing child content using TagHelperContext.GetChildContentAsync(useCachedResult: false).

For example, you can now write a custom RepeaterTagHelper like this:

And when you use it in a view like this:

You get rendered output like this:

Support for conditional attributes

You can now use conditional attributes with tag helpers. Unbound tag helper attributes that evaluate to null or false are automatically removed.

Tooling

Refactor class name on file name change

You now have the option in DNX based projects to refactor the class name when the file name for the class is changed.

Package search (CTRL+.) now limits suggestions to framework assemblies

From within Visual Studio 2015 you can use CTRL+. to find and install packages for APIs that you want to use. Previously the set of packages searched included all packages previously installed. This behavior has been refined to include only core framework packages.

Debug logger included in ASP.NET 5 project templates

The ASP.NET 5 project templates in Visual Studio now include the Debug logger by default so you can conveniently see logged messages in the Output window.

New project template folder structure

Based on community feedback we’ve updated the folder structure of the ASP.NET 5 project templates to provide clean separation between data models and view models.

Tag helper tool tips

You now get tool tips for tag helpers in the HTML editor. You can see which type implements the tag helper:

And also the properties for each bound attribute:

For tag helpers that have triple slash comments and have been built as a package you can also see the descriptions from the comments:

Summary

This release of ASP.NET 5 includes the first preview release of the .NET Execution Environment (DNX) for .NET Core on Mac and Linux. In addition, this release includes a variety of new runtime features and tooling enhancements. We hope you enjoy trying out ASP.NET 5 beta7! Please download and try out ASP.NET 5 beta7 today and let us know what you think on GitHub.

AJAX Control Toolkit Critical Update

$
0
0

Our friends at DevExpress have been hard at work on the AJAX Control toolkit and have an update available that should be installed to cover a critical security vulnerability that has existed prior to the v15.1.x version.

Brian Cardinale discovered the security vulnerability, a directory traversal issue, and has a blog post describing the issue in more detail.

Read more on the DexExpress blog: https://community.devexpress.com/blogs/aspnet/archive/2015/08/31/update-ajax-control-toolkit-to-patch-critical-security-vulnerability.aspx

Download an installer for the latest version of the toolkit now.

Introducing Microsoft ASP.NET WebHooks Preview

$
0
0

We are very pleased to announce ASP.NET WebHooks preview as a new addition to the ASP.NET family. WebHooks is a lightweight HTTP pattern providing a simple pub/sub model for wiring together Web APIs and SaaS services. When an event happens in a service, a notification is sent in the form of an HTTP POST request to registered subscribers. The POST request contains information about the event which makes it possible for the receiver to act accordingly.

Because of their simplicity, WebHooks are already exposed by a large number of services including Dropbox, GitHub, MailChimp, PayPal, Slack, Trello, and many more. For example, a WebHook can indicate that a file has changed in Dropbox, or a code change has been committed in GitHub, or a payment has been initiated in PayPal, or a card has been created in Trello – the possibilities are endless!

Microsoft ASP.NET WebHooks makes it easier to both send and receive WebHooks as part of your ASP.NET application:

  • On the receiving side, it provides a common model for receiving and processing WebHooks from any number of WebHook providers. It comes out of the box with support for Dropbox, GitHub, MailChimp, PayPal, Pusher, Slack, Stripe, Trello, and WordPress but it is easy to add support for more.
  • On the sending side it provides support for managing and storing subscriptions as well as for sending event notifications to the right set of subscribers. This allows you to define your own set of events that subscribers can subscribe to and notify them when things happens.

The two parts can be used together or apart depending on your scenario. If you only need to receive WebHooks from other services then you can use just the receiver part; if you only want to expose WebHooks for others to consume, then you can do just that.

The code targets ASP.NET Web API 2 and ASP.NET MVC 5, is available as OSS on GitHub, and as preview Nuget packages.

WebHooks Overview

WebHooks is a pattern which means that it varies how it is used from service to service but the basic idea is the same. You can think of WebHooks as a simple pub/sub model where a user can subscribe to events happening elsewhere. The event notifications are propagated as HTTP POST requests containing information about the event itself.

Typically the HTTP POST request contains a JSON object or HTML form data determined by the WebHook sender including information about the event causing the WebHook to trigger. For example, an example of a WebHook POST request body from GitHub looks like this as a result of a new issue being opened in a particular repository:

   1: {
   2:"action": "opened",
   3:"issue": {
   4:"url": "https://api.github.com/repos/octocat/Hello-World/issues/1347",
   5:"number": 1347,
   6:     ...
   7:   },
   8:"repository" : {
   9:"id": 1296269,
  10:"full_name": "octocat/Hello-World",
  11:"owner": {
  12:"login": "octocat",
  13:"id": 1,
  14:       ...
  15:     },
  16:     ...
  17:   },
  18:"sender": {
  19:"login": "octocat",
  20:"id": 1,
  21:     ...
  22:   }
  23: }

To ensure that the WebHook is indeed from the intended sender, the POST request is secured in some way and then verified by the receiver. For example, GitHub includes an ‘X-Hub-Signature’ HTTP header with a hash of the request body which is checked by the receiver implementation so you don’t have to worry about it.

The WebHook flow generally goes something like this:

  1. The WebHook sender exposes events that a client can subscribe to. The events describe observable changes to the system, for example that a new data item has been inserted, that a process has completed, or something else.
  2. The WebHook receiver subscribes by registering a WebHook consisting of four things:
    • A URI for where the event notification should be posted in the form of an HTTP POST request;
    • A set of filters describing the particular events for which the WebHook should be fired;
    • A secret key which is used to sign the HTTP POST request;
    • Additional data which is to be included in the HTTP POST request. This can for example be additional HTTP header fields or properties included in the HTTP POST request body
  3. Once an event happens, the matching WebHook registrations are found and HTTP POST requests are submitted. Typically, the generation of the HTTP POST requests are retried several times if for some reason the recipient is not responding or the HTTP POST request results in an error response.

As mentioned, Microsoft ASP.NET WebHooks support both sending and receiving WebHooks but in this blog we will focus on the receiving side. In a follow-up blog we will dive into the details of sending WebHooks.

Receiving WebHooks

Dealing with WebHooks depends on who the sender is. Sometimes there are additional steps registering a WebHook verifying that the subscriber is really listening. Some WebHooks provide a push-to-pull model where the HTTP POST request only contains a reference to the event information which is then to be retrieved independently. Often the security model varies quite a bit.

The purpose of Microsoft ASP.NET WebHooks is to make it both simpler and more consistent to wire up your API without spending a lot of time figuring out how to handle any particular variant of WebHooks.

To enable ASP.NET WebHooks, you first install the Nuget package for the WebHook provider or providers you want to receive WebHooks from. The Nuget packages are named Microsoft.AspNet.WebHooks.Receivers.* where the last part indicates the service supported. For example Microsoft.AspNet.WebHooks.Receivers.GitHub provides support for receiving WebHooks from GitHub and Microsoft.AspNet.WebHooks.Receivers.Custom provides support for receiving WebHooks generated by ASP.NET WebHooks.

Out of the box you can find support for Dropbox, GitHub, MailChimp, PayPal, Pusher, Slack, Stripe, Trello, and WordPress but it is possible to support any number of other providers. Here we will show how to receive WebHooks from GitHub – in follow up blogs we will describe in detail how to do it for other service and explain how you can extend the list yourself.

WebHook Configuration

Once you have the preview Nuget for the WebHook sender you want to receive WebHooks from, you need to configure it. This typically requires two parts:

  1. Configuring the WebHook sender,
  2. Configuring the receiver with security settings.

Configuration of the WebHook sender differs somewhat from service to service. Here we show how it works for GitHub but many other services provide a corresponding experience.

By installing Microsoft ASP.NET WebHooks you get a WebHook controller which accepts WebHook requests from an open-ended number of services. When a request arrives, it picks the appropriate receiver that you have installed for handling a particular WebHook sender. The URI of this controller is the WebHook URI that you register with the service and is of the form:

  • https://<host>/api/webhooks/incoming/<receiver>

For GitHub, the receiver name is github. For security reasons, many WebHook providers require that the the URI is an ‘https’ URI. Further, the URI has to be publically available so that Slack service can reach it. The easiest way of doing this is to deploy your ASP.NET application as an Azure Web App which you can do directly from Visual Studio.

To register the WebHook with GitHub, you obviously need a GitHub account. Then go to GitHub, pick a repository that you own, and select settings:

GitHubRepo

Under settings select WebHooks and Services and fill in the data in the red boxes (substituting the URI with yours):

GitHubWebHooksCreate

As secret, you should pick a value that has a high entropy. A good idea is to pick something like a SHA256 hash which you for example can get from QuickHash. Once you hit Add WebHook, GitHub sends a test event notification to check that the URI is correct. However, as we haven’t configured the receiver yet, this will show an error under Recent Deliveries.

Before going further, let’s therefore configure the receiver back in your Web Application. The first part of the configuration is done in WebApiConfig.cs where you add line 17 like this:

   1:using System.Web.Http;
   2:  
   3:namespace WebHookReceivers
   4: {
   5:publicstaticclass WebApiConfig
   6:     {
   7:publicstaticvoid Register(HttpConfiguration config)
   8:         {
   9:// Web API configuration and services
  10:  
  11:// Web API routes
  12:             config.MapHttpAttributeRoutes();
  13:  
  14:             config.Routes.MapHttpRoute(
  15:                 name: "DefaultApi",
  16:                 routeTemplate: "api/{controller}/{id}",
  17:                 defaults: new { id = RouteParameter.Optional }
  18:             );
  19:  
  20:// Load GitHub receiver
  21:             config.InitializeReceiveGitHubWebHooks();
  22:         }
  23:     }
  24: }

The second part is to set the secret token so that it can be verified by the receiver. This is done by setting the MS_WebHookReceiverSecret_GitHub app setting for your Web Application to the value of the secret from before. This can either be done directly in the Web.Config file or better yet, configured through the Azure portal:

AzureAppSettings

With the receiver configured, you should be able to go back to the WebHooks page on GitHub, hit Redeliver and see a 200 OK response:

GitHubWebHookConfirm

WebHook Processing

You are now ready to receive WebHooks from GitHub and process them however you want. To do this, once the receiver is done processing the WebHook, it calls one or more handlers which is where your code runs processing the actual event notification.

WebHookReceivers

Here is a sample handler illustrating the basic model. No registration is necessary – it will automatically get picked up and called:

   1:publicclass MyHandler : WebHookHandler
   2: {
   3:publicoverride Task ExecuteAsync(string receiver, WebHookHandlerContext context)
   4:     {
   5:// Here you can process the WebHook data
   6:  
   7:return Task.FromResult(true);
   8:     }
   9: }

In the case of GitHub, a handler could look like this:

   1:publicclass GitHubHandler : WebHookHandler
   2: {
   3:publicoverride Task ExecuteAsync(string receiver, WebHookHandlerContext context)
   4:     {
   5:string action = context.Actions.First();
   6:         JObject data = context.GetDataOrDefault<JObject>();
   7:  
   8:return Task.FromResult(true);
   9:     }
  10: }

The Actions property contains the name of the event and Data contains the actual notification which can either be operated on directly as a JObject instance or cast to an actual type if desired.

Trying it Out

Once deployed, we are now ready to try this out end-to-end: In the GitHub repository, we add a new issue like this:

GitHubNewIssue

And if we attach a debugger to the receiver then we will see the following:

GitHubWebHook

This should give a quick overview of what ASP.NET WebHooks can do for you. In follow-up blogs we will dive into the the receivers as well as how to build your own as well as of course sending WebHook yourself.

Your input is greatly appreciated so please send it my way. You can use my @frystyk twitter handle or email me at henrikn@microsoft.com.

Have fun!

Henrik

Integrating with Slack Using ASP.NET WebHooks Preview

$
0
0

In the blog Introducing Microsoft ASP.NET WebHooks Preview, we gave an overview of how to work with Microsoft ASP.NET WebHooks. Slack provides an interesting model where you can set up a WebHook to be fired when a certain trigger word is used in one of their messaging channels. In addition, it is possible for the WebHook to send data back to the channel which is very useful. For example, if you have a trigger word AskMe: then you can get the WebHook to respond like this:

SlackChannelMini

WebHook Configuration

To setup Slack WebHooks you need a Slack account. Then you configure the WebHook using what they call an Integration as follows:

SlackIntegrations

Pick the Outgoing WebHooks integration, select Add Outgoing WebHooks Integration and look for the fields Trigger Words, URLs, and Token. Fill in whatever trigger words and WebHook URI, and copy the Token for use later. The URI must have the form https://<host>/api/webhooks/incoming/slack

SlackWebHookConfiguration

Configuring Receiver

The last part is to configure the WebHook receiver. After having installed the Microsoft.AspNet.WebHooks.Receivers.Slack Nuget package into your ASP.NET application, this happens exactly like show in the blog Introducing Microsoft ASP.NET WebHooks Preview:

The first part of the configuration is done in WebApiConfig.cs where you add line 17 like this:

   1:publicstaticclass WebApiConfig
   2: {
   3:publicstaticvoid Register(HttpConfiguration config)
   4:     {
   5:// Web API configuration and services
   6:  
   7:// Web API routes
   8:         config.MapHttpAttributeRoutes();
   9:  
  10:         config.Routes.MapHttpRoute(
  11:             name: "DefaultApi",
  12:             routeTemplate: "api/{controller}/{id}",
  13:             defaults: new { id = RouteParameter.Optional }
  14:         );
  15:  
  16:// Load Slack receiver
  17:         config.InitializeReceiveSlackWebHooks();
  18:     }
  19: }

The second part is to set the secret token so that it can be verified by the receiver. This is done by setting the MS_WebHookReceiverSecret_Slack app setting for your Web Application to the value of the secret Token obtained from before. As stated in the blog Introducing Microsoft ASP.NET WebHooks Preview, the preferred way to do this is to set it in the Azure Portal:

AzureAppSettings

Defining a Handler

Slack sends WebHook data in the form of HTML Form data so we read it as a NameValueCollection. Further, as the Slack WebHook can return data, we use the Response property on the WebHookHandlerContext to define the data we want to return. The SlackResponse is just a helper formatting the response as expected by Slack.

   1:publicclass SlackWebHookHandler : WebHookHandler
   2: {
   3:publicoverride Task ExecuteAsync(string generator, WebHookHandlerContext context)
   4:     {
   5:         NameValueCollection nvc;
   6:if (context.TryGetData<NameValueCollection>(out nvc))
   7:         {
   8:string question = nvc["subtext"];
   9:string msg = string.Format("The answer to '{0}' is '{1}'.", question, "Often");
  10:             SlackResponse reply = new SlackResponse(msg);
  11:             context.Response = context.Request.CreateResponse(reply);
  12:         }
  13:return Task.FromResult(true);
  14:     }
  15: }

Trying it Out

Once deployed, we are ready to try this out: In a Slack channel write something like this AskMe: You there? You should now be called in your handler and see a response on the Slack channel like this:

SlackChannel

This should hopefully be enough to get you started receiving WebHooks from Slack using ASP.NET WebHooks Preview.

Have fun!

Henrik

Integrating with Salesforce using ASP.NET WebHooks Preview

$
0
0

In the blog Introducing Microsoft ASP.NET WebHooks Preview, we gave an overview of how to work with Microsoft ASP.NET WebHooks. Out of the box we provide support for a variety of existing WebHooks providers such as Dropbox, GitHub, MailChimp, PayPal, Slack, Trello, and many more.

Salesforce does not support classic WebHooks, but they do have a concept called Outbound Soap Messages which shares many of the same characteristics. As a result, it is possible to receive these messages using ASP.NET WebHooks which we will describe here. To support receiving Outbound Soap Messages you need to install the Microsoft.AspNet.WebHooks.Receivers.Salesforce Nuget package into your Web Application but more about that later.

Configuring Outbound Soap Messages

In order to setup Outbound Soap Messages you need a Salesforce developer account. Then login to Salesforce.com and select Setup at the top of the page:

SalesforceHome

Then you select Build | Create | Workflow and Approvals | Outbound Messages.

SalesforceCreate

Here you may see an Understanding Workflow page, which you can read if desired, and then continue to the Outbound Message page where you select New Outbound Message:

SalesforceOutbound

Here you pick an object such as Lead and then you fill in the required information. Just like described in the blog Introducing Microsoft ASP.NET WebHooks Preview the URI must be public and have the form https://<host>/api/webhooks/incoming/sfsoap. If you check Send Session ID, then the outbound message will contain a session ID which can be used for subsequent calls back to Salesforce. Lastly you pick the message fields you want in the notification.

SalesforceEditOutbound

Now we have defined a message – next we have to define a workflow rule which uses the message. Select Build | Create | Workflow and Approvals | Workflow Rules. Here you may again see the Understanding Workflow page, and after that you select New Rule:

SalesforceCreateRule

Fill in the required fields, for example like below, and save:

SalesforceEditRule

Finally, it’s important to check that the rule is marked as Active:

SalesforceRuleActive

Configuring Receiver

The next step is to configure the WebHook receiver. First make sure you install the Microsoft.AspNet.WebHooks.Receivers.Salesforce Nuget package into your ASP.NET application. Then the registration happens exactly like in the blog Introducing Microsoft ASP.NET WebHooks Preview by adding line 21 to the WebApiConfig.Register method:

   1:using System.Web.Http;
   2:  
   3:namespace WebHookReceivers
   4: {
   5:publicstaticclass WebApiConfig
   6:     {
   7:publicstaticvoid Register(HttpConfiguration config)
   8:         {
   9:// Web API configuration and services
  10:  
  11:// Web API routes
  12:             config.MapHttpAttributeRoutes();
  13:  
  14:             config.Routes.MapHttpRoute(
  15:                 name: "DefaultApi",
  16:                 routeTemplate: "api/{controller}/{id}",
  17:                 defaults: new { id = RouteParameter.Optional }
  18:             );
  19:  
  20:// Load Salesforce receiver
  21:             config.InitializeReceiveSalesforceWebHooks();
  22:         }
  23:     }
  24: }

Set the MS_WebHookReceiverSecret_SalesforceSoap application setting to the value of your Organizational ID which you can find on the Setup page under Administer | Company Profile | Company Information:

SalesforceOrgId

As stated in the blog Introducing Microsoft ASP.NET WebHooks Preview, the preferred way to do this is to set it in the Azure Portal:

AzureAppSettings

Defining a Handler

Let’s define a handler that can process the incoming message from Salesforce – something like this will do:

   1:publicclass SalesforceHandler : WebHookHandler
   2: {
   3:publicoverride Task ExecuteAsync(string receiver, WebHookHandlerContext context)
   4:     {
   5:         SalesforceNotifications nots = context.GetDataOrDefault<SalesforceNotifications>();
   6:string sessionId = notifications.SessionId;
   7:string company = notifications.Notifications.First()["Company"];
   8:return Task.FromResult(true);
   9:     }
  10: }

Trying it Out

After deploying your Web Application, we are now ready to try it out. Do this by creating a new Lead as follows: Go to the Leads menu and select New:

SalesforceLeadsNew

Then fill in the entry picking values that match the filter you set up for the Lead rule earlier and then hit Save.

SalesForceLeadsEdit

When running with the debugger attached you should see something like this:

SalesforceRun

The session ID is available for subsequent calls and you can inspect the data from the notification (or multiple notifications) as well.

Finally, you can optionally inspect the delivery status of the messages by going to Build | Create | Workflow and Approvals | Outbound Messages and then select View Message Delivery Status. It should give you an overview of which messages were delivered:

SalesforceDelivery

That’s it – have fun!

Henrik


ASP.NET Community Standup - September 8, 2015

$
0
0

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 is back from vacation, and Scott feels that he has tasted retirement… and it is good.  This week, Jon is in the office with Damian and there are a number of things that have happened since the last standup.

  • Beta 7 was released.  This is the first release with cross-platform .NET core for Mac OS X and Linux that does not depend on Mono.  More details on the blog.
  • Beta 8 is underway and the due date was delayed by two weeks until October 5.  More roadmap details are online
    • More support and content coming from the .NET team in this release
    • More cross platform support and support for other Linux distros.
    • Work on the installation processes for Linux and PKGs for Mac
  • There is some investigation into breaking up the Web Tools Extensions so that the various components of ASP.NET 5 can be installed separately (DNX, Web Tools, Package Cache)
  • No new feature work is being developed - only completing existing APIs and features
  • A number of features in progress have been cut from the RTM planning and will be rescheduled for after RTM
    • SignalR and Web Pages are the most prominent items delayed

Big announcement preview: Kestrel is the only server that will be shipped.

  • The Helios server that interfaced with IIS and would rely on System.Web to boot up a CLR
  • Windows Nano server with a yet to be built Host that would be native for IIS
  • WebListener server that plugged in to the command-line host

Bottom line: the team had too many hosts and servers to manage and get to RTM, and instead would prefer to focus on delivering one really good host and server experience.  IIS will be supported through the HTTPPlatformHandler.  Scott has a good blog post about using IIS to start another process to proxy requests to it.   This allows the ASP.NET team to really focus on performance in the DNX host process and the Kestrel server.

This model also allows the Windows experience to mimic the Linux experience.  On Linux you would use nginx to proxy requests to kestrel.  On Windows you will use IIS to proxy requests to kestrel.  There is some work being done on IIS to ensure that Kestrel production experience is improved with dnx command support.

Damian explained that:

  • Helios will not be shipped
  • WebListener will not be shipped
  • Kestrel and DNX are the only server and host processes that will be shipped
  • IIS will manage starting and stopping the dnx and kestrel process that we typically run from the command line today.  All IIS handlers in the request pipeline will still function and can modify the dnx kestrel pipeline.  The dnx and kestrel process will run outside of IIS.
  • Currently, performance with this IIS model is starting to wane after 20k requests per second
  • More details and guidance to come

Questions:

Question: How many people work on ASP.NET at Microsoft?

Outside of the 4 PMs (Damian and the three that report to him).  There are 8 engineers working on dnx, another 8 on MVC, 2 or 3 working on middleware, 8 people working on Entity Framework. A total of 25 working on the runtime.  The tooling team that works on Visual Studio is another 13.  There are 5 development managers on ASP.NET  The .NET team that manages the frameworks is much larger than the ASP.NET team.  The total between the two groups is about 100.

Question: Are the ASP.NET Webhooks related to ASP.NET 5?

No, this is directly related to ASP.NET WebAPI 2 and ASP.NET 4.6

Question: If I wanted to create MVC middleware in a separate assembly with controllers and mount them in a custom URL prefix, what are my options?

There are some new features in MVC 6 that enable these features, but a full multi-tenancy set of features are not coming in this release. Post questions like this in the MVC repository on GitHub for further discussion

Question: What happened to the Autofac and Ninject implementations of the dependency injection facade?

These were proof-of-concept implementations by Microsoft, not intended to be supported by Microsoft. Autofac and Ninject have taken over the packages and are now managing them

Question: Are the ASP.NET team members going to attend DockerCon Europe?

We are not sure who may or may not will be attending, but we assume that some Microsoft speakers will be there. Scott pointed out that the container technology is not being done by the ASP.NET team, but we are implementing several items on top of that technology including the ASP.NET 5 docker image for Linux and Windows.

Question: Have you tested Yeoman generators on Windows 10?

They have been updated to beta 7 and should be available.  They are part of the ASP.NET sign off process.

Question: Any plans on hosting a .NET room at FOSDEM?

We're not planning on it this year, but after .NET Core and ASP.NET 5 Linux versions in production, we will be ready for it next year.

Question: What about support for debugging in Visual Studio Code?

They are working very hard on this, and it will be in a future release. Now that .NET Core is running on Linux and Mac, this can be considered and built

Question: When is dnu publish output going to be solidified?

We are not aware of any major changes coming to the publish command.  If there is a specific issue you are seeing, please log it in the dnx repository on GitHub.

Question: Will it be possible in VS to stop debugging and keep IIS running?

Damian never starts debugging in Visual Studio with F5, and instead prefers to start with Ctrl-F5 and attach the debugger when needed. Visual Studio starts extra features when you start with debugger, and the process cannot be re-used across processes when the debugger is stopped and restarted.

Question: Any new talk on markup minification and line-termination?

This was delayed until after RTM.  In the meantime, the compilation pipeline in Razor can be modified at compile-time.  You could also write some middleware to modify the HTML content as the stream is output.

Question: How can I control assembly probing in ASP.NET 5?

You can't….  ASP.NET 5 and dnx takes over the loading of assemblies.  This is how we can load assemblies from NuGet packages quickly at run-time.

Question: What role do the feature collection APIs play in the new runtimes?

There are 2 feature collections: server and request.  They are a collection of features that describe what is available on the server or what is in the request and response.  The web server populates a bunch of those and middleware can work with them as well.  This gives a flexible core set of APIs that can be adapted as ASP.NET advances.

Question: If Kestrel is the only server being shipped, does this mean WebListener is going away?

Yes… Kestrel will work cross-platform, and the community is welcome to work on and build any server they would like. WebListener is built on top of Http.sys, a kernel mode driver in Windows.  In order to add new features to WebListener, we need to wait for windows features.  Kestrel is completely owned by ASP.NET and can have features added as needed, like HTTP2.

Question: What if I wanted to host kestrel in my own process?

There is no self-host model.  Dnx is a hosted model, where you pass in the application that you want dnx to host.  This is similar to node where you execute node and pass in the application that you want node to run.

Question: Will we be able to select Local IIS in the Debug settings for Visual Studio?

Yes, this is being planned for the RC release

Question: Is there support coming for OData?

There is no planned work for Odata support in MVC 6.  Please ask more about this in the home repository and we can follow-up on it.

Question: I'm having a problem locating kestrel with dnu restore in Beta 7, what should I do?

There was a change made to name of the package for kestrel. Check the announcements repo issues list for more details about breaking changes.

Question: Scott mentioned he recorded a Microsoft Virtual Academy about ASP.NET 5, when can we expect that to be released?

It should be published early next week and we'll have details in the next Community Standup.

Links of the Week:

Tune in on Tuesday September 15th at 15:45 Pacific Standard time for the next stand up.  Get your questions answered by the team live on video!

Sending WebHooks with ASP.NET WebHooks Preview

$
0
0

In the blog Introducing Microsoft ASP.NET WebHooks Preview, we gave an overview of how to work with Microsoft ASP.NET WebHooks. We mentioned that it is not only possible to receive WebHooks from others but also to add support for sending WebHooks from your Web Application. This blog goes into detail on how to do that.

Sending WebHooks is slightly more involved in that there are more things to keep track of. In order to support other APIs registering for WebHooks from your ASP.NET application, we need to provide support for:

  • Exposing which events subscribers can subscribe to, for example Item Created and Item Deleted;
  • Managing subscribers and their registered WebHooks which includes persisting them so that they don’t disappear;
  • Handling per-user events in the system and determine which WebHooks should get fired so that WebHooks go to the correct receivers. For example, if user A caused an Item Created event to fire then determine which WebHooks registered by user A should be sent. We don’t want events for user A to be sent to user B
  • Sending WebHooks to receivers with matching WebHook registrations.

Microsoft ASP.NET WebHooks help you throughout this process making it simpler to support WebHooks on your own:

  • It provides support for managing which events users can subscribe to and allowing these to be exposed to clients;
  • It provides a mechanism for managing registered WebHooks. This can be done using an API controller for registering/unregistering WebHooks using REST or an MVC controller for a UI oriented approach. In addition, it provides a pluggable model for persisting WebHook registrations and out-of-box support for storing WebHook registrations in Azure Table Storage;
  • It provides a mechanism for finding matching WebHook registrations and for determining which WebHooks to send as a result;
  • It supports sending WebHooks handling errors and retrying requests for a number of times before giving up.

Note: We are adding topics to the Microsoft ASP.NET WebHooks online documentation so please also check there for additional details as they become available.

Creating a Sample Web Application

First we need an ASP.NET Web Application which has some form of authentication enabled so that we know who the client user is. The reason for this is that we want to only have WebHooks go to the users who registered for them. In this example we create up an MVC + Web API project using Individual User Accounts as follows:

WebHookSenderProject

Adding the Nugets

The support for sending WebHooks is provided by the following Nuget packages:

  • Microsoft.AspNet.WebHooks.Custom: This package provides the core functionality for adding WebHook support to your ASP.NET project. The functionality enables users to register WebHooks using a simple pub/sub model and for your code to send WebHooks to receivers with matching WebHook registrations.
  • Microsoft.AspNet.WebHooks.Custom.AzureStorageThis package provides optional support for persisting WebHook registrations in Microsoft Azure Table Storage.
  • Microsoft.AspNet.WebHooks.Custom.MvcThis package exposes optional helpers for accessing WebHooks functionality from within ASP.NET MVC Controllers. The helpers assist in providing WebHook registration through MVC controllers as well as creating event notification to be sent to WebHook registrants.
  • Microsoft.AspNet.WebHooks.Custom.ApiThis package contains an  optional set of ASP.NET Web API Controllers for managing filters and registrations through a REST-style interface.

In this example we will use all four packages for providing a basic WebHooks implementation which stores WebHook registrations in Azure Table Storage and exposes a REST API for subscribing to WebHooks. However, ASP.NET WebHooks is built around Dependency Injection and so most parts of the system are pluggable allowing you to provide alternative implementations as needed.

After adding the four packages to your project, initialize them by adding the following three lines to WebApiConfig.Register:

public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services

// Web API routes
config.MapHttpAttributeRoutes();

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);

// Load Web API controllers and Azure Storage store
config.InitializeCustomWebHooks();
config.InitializeCustomWebHooksAzureStorage();
config.InitializeCustomWebHooksApis();
}
}

Defining Event Filters

Now let’s look at defining the set of event filters that consumers of your WebHooks can use when subscribing for event notifications. The filters indicate which events the consumer is interested in. By default, the system registers awildcard filter which allows users to register for all events. Event filters are registered by providing one or more implementations of the IWebHookFilterProvider interface which simply exposes GetFiltersAsync. Add a class called MyFilterProvider like below defining two events (event1 and event2):

/// <summary>
/// Use a IWebHookFilterProvider implementation to describe the events that users can
/// subscribe to. A wildcard is always registered meaning that users can register for
/// "all events". It is possible to have 0, 1, or more IWebHookFilterProvider
/// implementations.
/// </summary>
publicclass MyFilterProvider : IWebHookFilterProvider
{
privatereadonly Collection<WebHookFilter> filters = new Collection<WebHookFilter>
{
new WebHookFilter { Name = "event1", Description = "This event happened."},
new WebHookFilter { Name = "event2", Description = "This event happened."},
};

public Task<Collection<WebHookFilter>> GetFiltersAsync()
{
return Task.FromResult(this.filters);
}
}

When ASP.NET WebHooks starts up, it looks for all IWebHookFilterProvider implementations and gathers the combined set of event filters. The filters are made available so that they can be incorporated into an MVC UI or exposed through the REST-style API for managing registrations.

Managing WebHook Subscriptions

WebHook subscriptions are managed through an interface called IWebHookStore which provide an abstraction for querying, inserting, updating, and deleting subscriptions. The default IWebHookStore implementation is in-memory-only, but for more realistic scenarios, you can use the Azure Table Storage implementation, or write your own. Just like the store can be backed by any number of implementations, the store can be accessed in a number of ways:

SubscriptionStore

That is, you can for example write an MVC controller which exposes subscription management, or you can use the provided Web API implementation which exposes it using a REST-style interface. In this example we will go with the Web API and store the data in Azure Table Storage, the but you can provide the exact experience you want.

We just use the local Development Storage so set the MS_AzureStoreConnectionString connection string as follows:

<connectionStrings>
<addname="MS_AzureStoreConnectionString"connectionString="UseDevelopmentStorage=true;"/>
</connectionStrings>

Sending Notifications

Let’s generate an event! Events are matched against the registered WebHooks and if matches are found then an event notification is fired in the form of a WebHook. Generating WebHook notifications typically happens from within an MVC controller or a Web API controller but can actually happen from anywhere. In the following we will focus on sending them from an MVC controller and a Web API controller.

Add an empty MVC Controller called NotifyController with a Submit action that generates an event using the NotifyAsync method:

[Authorize]
publicclass NotifyController : Controller
{
[HttpPost]
public async Task<ActionResult> Submit()
{
// Create an event with action 'event1' and additional data
await this.NotifyAsync("event1", new { P1 = "p1" });

returnnew EmptyResult();
}
}

Note that we only want WebHooks to be sent to the current user. That is, we don’t want user A’s events going to user B and vice versa. This means that to generate an event we must have a valid user ID. In the case of the controllers we do this by ensuring that the user is authenticated using the [Authorize] attribute.

The input data allows the submitter to include additional data in the WebHook which is then sent to matching receivers. This can be anything that the notification needs to convey data about the event.

Similarly, add an empty Web API Controller called NotifyApiController with a Post action that generates an event using the NotifyAsync method:

[Authorize]
publicclass NotifyApiController : ApiController
{
public async Task Post()
{
// Create an event with 'event2' and additional data
await this.NotifyAsync("event2", new { P1 = "p1" });
}
}

The use of actions and data is identical to that of MVC controllers and again, we require authentication to get a valid user.

Trying it Out

That’s all the configuration we need. However, in order to try it out we need to set up a test client that can subscribe and receive WebHooks. For this scenario we just add the test client straight to the current Web Application project. In a more realistic scenario, it would of course be a separate project, but this suffices to show the point. The flow we are going for is as follows:

WebHookFlow

To set up the test client, add the Microsoft.AspNet.WebHooks.Receivers.Custom to your Web Application project and add this to your WebApiConfig.Register method:

public static void Register(HttpConfiguration config)
{
// Web API configuration and services

// Web API routes
config.MapHttpAttributeRoutes();

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);

// Load Web API controllers and Azure Storage store
config.InitializeCustomWebHooks();
config.InitializeCustomWebHooksAzureStorage();
config.InitializeCustomWebHooksApis();
config.InitializeCustomWebHooks();
}
 
Configure the receiver with the following Application Setting added to Web.Config:
 
<appSettings>
<addkey="MS_WebHookReceiverSecret_Custom"value="12345678901234567890123456789012"/>
</appSettings>

Next, we add a TestHandler class to process incoming WebHooks like this:
 
public class TestHandler : WebHookHandler
{
public override Task ExecuteAsync(string receiver, WebHookHandlerContext context)
{
return Task.FromResult(true);
}
}

To simulate subscribing and triggering events, we mock up a simple UI in the well-known ASP.NET home page. Open the file Views/Home/Index.cshtml and add the following content right under the jumbotron div element. In this scenario we subscribe to all events by not including any filters in the subscribe request.
 
Note: Make sure the WebHookURI property points to your actual server by setting the HTTP port to the correct value, for example http://localhost:59927/api/webhooks/incoming/custom:

<form onsubmit="return subscribe()">
Subscribe to all events <input type="submit" value="submit">
</form>
<form onsubmit="return unsubscribe()">
Unsubscribe from all events <input type="submit" value="submit">
</form>
<form onsubmit="return notifymvc()">
Trigger notification through MVC controller <input type="submit" value="submit">
</form>
<form onsubmit="return notifyapi()">
Trigger notification through Web API controller <input type="submit" value="submit">
</form>

<script>
function subscribe() {
$.ajax({
type: "POST",
url: "/api/webhooks/registrations",
data: JSON.stringify({
WebHookUri: "http://localhost:59927/api/webhooks/incoming/custom",
Secret: "12345678901234567890123456789012",
Description: "My first WebHook!"
}),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data, status) { alert(status); },
failure: function(errMsg) { alert(errMsg); }
});
returnfalse;
}

function unsubscribe() {
$.ajax({
url: "/api/webhooks/registrations",
type: 'DELETE',
success: function (data, status) { alert(status); },
failure: function(errMsg) { alert(errMsg); }
});
returnfalse;
}

function notifymvc() {
$.post("/notify/submit",
{ },
function (data, status) { alert("Data: " + data + "\nStatus: " + status); });
returnfalse;
}

function notifyapi() {
$.post("/api/notifyapi",
{ },
function (data, status) { alert("Data: " + data + "\nStatus: " + status); });
returnfalse;
}
</script>

That should give you four very fancy buttons on the home page looking like this:

SenderTestPage

First you have to authenticate by logging in using the login flow in the top right corner. Just create a new user/password – the details don’t matter:

SenderUser

When you hit Subscribe, an entry should be stored in Azure Table Storage. You can inspect that this happened by looking at the store in Visual Studio (note that the content is encrypted with a roll-over key so that none of the client secrets are visible).

Subscription

Now hit either of the Trigger buttons on the home page which will fire off events. As a result, you should be able to see this in your handler like this:

HandlerDebug

That’s it – you now have full support for sending WebHooks!

Have fun!

Henrik

Deploy to Azure from GitHub with Application Insights

$
0
0

Browsing GitHub the other day I found an interesting button in README: Deploy to Azure. This button intrigued me to say the least. With one click I can create my own instance of that web app and try it out. Isn’t it great? And it’s very easy to insert into your own GitHub repo. But every app should include monitoring! So I’ll show you how to extend the button to create a new Application Insights resource. Anyone who deploys your app also gets their own web app monitor that shows the performance and usage of their instance of the app.

image

Just a button

There is a nice blog post on how to implement this button for your project. It is very straightforward. All you have to do is to insert this line of code into Readme.md:

   1: [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://azuredeploy.net/) 

There are some gotchas:

  1. Your repository should be public.
  2. If your application is .NET and require compilation, the solution should compile in a Visual Studio without extra manual configuration.
  3. For application with NuGet dependencies you have to enable NuGet restore.
  4. Your readers need an Azure subscription.

When a reader clicks Deploy to Azure nice deployment wizard will help them to deploy the application from GitHub to Azure.

Application Example

To demonstrate the power of the Deploy to Azure feature, I’ve implemented a simple private NuGet feed project following instructions from docs.nuget.org. Here is a resulting application: https://github.com/SergeyKanzhelev/PrivateFeed.

image

Now if you need a share your test packages with somebody it is very easy to do:

  1. Deploy this repository to Azure using Deploy to Azure button
  2. Open KuDu console at http://<your site name>.scm.azurewebsites.net
  3. Go to Debug Console> CMD
  4. Use command cd site\wwwroot\app_data to open App_Data folder
  5. Drag and drop your *nupkg files to the folder
  6. Use http://<your site name>.azurewebsites.net/nuget as a nuget feed

If you already have your Azure subscription it will take you a minute to set up a private NuGet feed now.

Template customization

Once you have deployment set up you can start customizing it. All template customization is done by creating new file in your repository called azuredeploy.json. This blog post explains how basic template looks like and how customization works.

For private NuGet feed it is important to set up a private key for packages publishing from command line. Following instructions from the blog post you need to add new parameter for your template:

   1:"NuGetApiKey": {
   2:"type": "string",
   3:"defaultValue": "{7F2C2BC0-CBEE-41B1-9963-9C4F164CE8C9}"
   4: },

And than use this parameter to set websites settings:

   1:"resources": [
   2:   {
   3:"apiVersion": "2014-04-01",
   4:"type": "config",
   5:"name": "web",
   6:"dependsOn": [
   7:"[concat('Microsoft.Web/Sites/', parameters('siteName'))]"
   8:     ],
   9:"properties": {
  10:"appSettings": [
  11:         {
  12:"name": "apiKey",
  13:"value": "[parameters('NuGetApiKey')]"
  14:         }
  15:       ]
  16:     }
  17:   },

Now you’ll have this setting set for your application:

image

Monitoring for your application

Every application needs monitoring. Application Insights provides you visibility into application performance and reliability. Since Application Insights is part of Azure, it is very easy to set it up and configure monitoring for your application using a deployment template. All you need is:

  1. Create Application Insights resource in Azure
  2. Get the Instrumentation Key of that resource and set it for your application
  3. Enable Application Insights Azure WebSite extension

Here is how you can do it using azure template.

Crate Application Insights component

First, new component needs to be created. Everything in Azure is a resource of certain provider. For Application Insights components provider is called Microsoft.Insights. Let’s give Application Insights component the same name as your application:

   1: {
   2:"apiVersion": "2014-04-01",
   3:"name": "[parameters('siteName')]",
   4:"type": "Microsoft.Insights/components",
   5:"location": "Central US",
   6:"dependsOn": [ ],
   7:"tags": { "[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', parameters('siteName'))]": "Resource" },
   8:"properties": { "ApplicationId": "[parameters('siteName')]" }
   9: },

You may note I created a hidden link between Application Insights component and web site. This link is needed so Azure portal will show Application Insights component in the list of Performance Monitoring providers.

Set instrumentation key

Instrumentation key is a guid that tells Application Insights SDK where to send telemetry. In Azure templates terms it is a property of Application Insights component. As we want to use instrumentation key to configure website we need to tell azure to create Application Insights component first. So I set a dependsOn property for website:

   1:"name": "[parameters('siteName')]",
   2:"type": "Microsoft.Web/Sites",
   3:"dependsOn": [
   4:"[concat('Microsoft.Web/serverFarms/', parameters('hostingPlanName'))]",
   5:"[concat('Microsoft.Insights/components/', parameters('siteName'))]"
   6: ],

I also use reference function to get property of one resource and use it in another:

   1: {
   2:"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
   3:"value": "[reference(concat('Microsoft.Insights/components/', parameters('siteName'))).InstrumentationKey]"
   4: }

Enable Application Insights Azure WebSite extension

Last step configuring Application Insights is an actual deployment of Application Insights SDK so it will monitor your website. You need to enable Azure WebSite extension using the siteextensions resource:

   1: {
   2:"apiVersion": "2014-04-01",
   3:"name": "Microsoft.ApplicationInsights.AzureWebSites",
   4:"type": "siteextensions",
   5:"dependsOn": [
   6:"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]",
   7:"[resourceId('Microsoft.Web/Sites/config', parameters('siteName'), 'web')]",
   8:"[resourceId('Microsoft.Web/sites/sourcecontrols', parameters('siteName'), 'web')]"
   9:   ],
  10:"properties": { }
  11: }

You can see complete deployment template at GitHub.

Result

Once you updated template – you see that the first screen of wizard now has extra parameter “NuGet Api Key”:

image[34]

While deploying you will see that Application Insights component was created and site extension was enabled for your website:

image

 

And when you browsed your application you will see all your monitoring data in portal on summary page. You can open Application Insights blade or from WebSite blade go to Tools> Performance Monitoring.

image

 

And search blade:

image

Note, to see browser information you need to modify your application and inject JavaScript snippet.

Summary

Azure provides great flexibility in deployment automation. It is easy to deploy your application, configure it and enable monitoring for it in a single click. With the GitHub integration you can see this power. Give it a try!

Integrating with Instagram using ASP.NET WebHooks Preview

$
0
0

In the blog Introducing Microsoft ASP.NET WebHooks Preview, we gave an overview of how to work with Microsoft ASP.NET WebHooks. We described how you get out-of-the-box support for a variety of WebHooks providers such as Dropbox, GitHub, MailChimp, PayPal, Slack, Salesforce, Trello, as well as being able to write your own.

In this blog we describe our latest addition integrating with Instagram which enables you to get notified as new images and videos are posted to their service. Instagram WebHooks support four kinds of subscriptions:

  • Users: receive notifications when users registered with your application post new photos.
  • Tags: receive notifications when a new photo is tagged with specific tags.
  • Locations: receive notifications when new photos are posted and tagged with a specific location.
  • Geographies: receive notifications when new photos are posted in a given geo location defined by a center point and radius.

The last one is my personal favorite as it is very easy to use and provides great opportunities for integration. In this blog we show how to subscribe using a geo location and receive updates as new images are posted.

Note: You can access the latest ASP.NET WebHooks online documentation for updates as well.

Configuring an Instagram Client

Assuming you have an Instagram account, go to their developer portal and define a Client which we will use for setting up the subscriptions. It should look something like this:

InstagramCreateClient

Note the Client ID and Client Secret– you will need these later. Also note that we don’t provide any subscription information here such as the WebHook URI or the kind of subscription. Rather, Instagram supports managing subscriptions through a REST API enabling you to list, create, and delete subscriptions for a given client.

Configuring Receiver

Before we go through the subscription process, let’s create a new Web Application project – a straight up Web API project will do:

NewProject

Let’s set up the ASP.NET WebHook Receiver. First make sure you install the Microsoft.AspNet.WebHooks.Receivers.Instagram Nuget package into your ASP.NET application. Then the registration happens exactly like in the blog Introducing Microsoft ASP.NET WebHooks Preview by adding this line to the WebApiConfig.Register method:

namespace WebHookReceivers
{
publicstaticclass WebApiConfig
{
publicstaticvoid Register(HttpConfiguration config)
{
// Web API configuration and services

// Web API routes
config.MapHttpAttributeRoutes();

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);

// Load receivers
config.InitializeReceiveInstagramWebHooks();
}
}
}

This time we set two application settings using the Instagram Client ID and Secret from before. As stated in the blog Introducing Microsoft ASP.NET WebHooks Preview, the preferred way to do this is to set it in the Azure Portal:

<appSettings>
<addkey="MS_WebHookReceiverSecret_InstagramId"value="Instagram Client ID"/>
<addkey="MS_WebHookReceiverSecret_Instagram"value="Instagram Client Secret"/>
</appSettings>

Configuring Instagram WebHook Client

The InstagramWebHookClient class makes it easier to talk to the Instagram subscription API as well as to retrieve information about images. It exposes methods for subscribing to any of the four mechanisms provided by Instagram as well as unsubscribing, and for getting additional information about posted images.
 
To wire it up, create a new class called Dependencies.cs (or if you want to be fancy, use a Dependency Injection Engine with ASP.NET Web API of your choice):
 
publicstaticclass Dependencies
{
privatestatic InstagramWebHookClient _client;


publicstaticvoid Initialize(HttpConfiguration config)
{
_client = new InstagramWebHookClient(config);
}


publicstatic InstagramWebHookClient Client
{
get { return _client; }
}
}

Now wire this up in the WebApiConfig.Register method by adding this line:
 
publicstaticclass WebApiConfig
{
publicstaticvoid Register(HttpConfiguration config)
{
// Web API configuration and services

// Web API routes
config.MapHttpAttributeRoutes();

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);

// Wire up dependencies
Dependencies.Initialize(config);

// Load receivers
config.InitializeReceiveInstagramWebHooks();
}
}

The first place we will use the InstagramWebHookClient is in the WebHook Handler. The reason for this is that Instagram doesn’t include information about the posted media directly in the WebHook so we have to go get it separately. An example of a WebHook notification from Instagram looks like this:
 
[
{
"subscription_id": "1",
"object": "geography",
"object_id": "12345678",
"changed_aspect": "media",
"time": 1297286541
}
...
]

This means that we have to look up information about what media was actually posted as a second step. In the case of a geo location subscription, this can be done simply using the Client ID and Client Secret which we already have. For most other Instagram requests you need an OAuth token which takes more steps to obtain so here we will focus on images posted within a geo location.

Adding WebHook Handler

Now lets put together the WebHooks handler. For geo location subscriptions we simply use the InstagramWebHookClient for retrieving additional data and then extract information about the images posted:
 
publicclass InstagramWebHookHandler : WebHookHandler
{
public InstagramWebHookHandler()
{
this.Receiver = "instagram";
}

publicoverride async Task ExecuteAsync(string generator, WebHookHandlerContext context)
{
// Get the WebHook client
InstagramWebHookClient client = Dependencies.Client;

// Convert the incoming data to a collection of InstagramNotifications
var notifications = context.GetDataOrDefault<IEnumerable<InstagramNotification>>();
foreach (var notification in notifications)
{
// Use WebHook client to get detailed information about the posted media
var entries = await client.GetRecentGeoMedia(context.Id, notification.ObjectId);
foreach (JToken entry in entries)
{
// Get direct links and sizes of media
var thumbnail = entry["images"]["thumbnail"].ToObject<InstagramMedia>();
var lowres = entry["images"]["low_resolution"].ToObject<InstagramMedia>();
var std = entry["images"]["standard_resolution"].ToObject<InstagramMedia>();
}
}
}
}
 
The GetRecentGeoMedia method automatically keeps track of where it is so you only see the same image information once as long as you use the same InstagramWebHookClient instance. In the case above we extract information about three different image resolutions (thumbnail, low resolution, and standard resolution). However, the information provide by Instagram is very rich and we can extract much other information as well. Here are some examples what you can get from the entry above:
 
// Get link to the media on the Instagram website
string link = entry.Value<string>("link");

// Get caption for the media
var caption = entry["caption"].ToObject<InstagramCaption>();

// Get information about the user posting the media
var user = entry["user"].ToObject<InstagramUser>();

// Get location information about where the media was recorded.
var location = entry["location"].ToObject<InstagramLocation>();
 

Subscribing to Instagram

The last piece missing is subscribing to Instagram so that we can start receive notifications. To subscribe to a geo location, we need three parameters: The latitude and longitude as well as a radius defining the area we are looking for. The radius is described in meters and must be less than 5000 meters. I have had luck using the latitude and longitude of Times Square in New York and a radius of 5000 meters but it depends on the time of day. You can get the latitude and longitude using either Bing Maps or Google Maps. Using the former you create a push pin which will show you the coordinates:
 
TimesSquare

Subscriptions are persisted by Instagram so we only have to subscribe once in order to receive notifications for a long time. You can imagine this being wired up in a variety of ways but here we use a simple controller exposing three actions for subscribing and unsubscribing. Create a new empty Web API controller class called InstagramSubscriptionController and fill it in as follows:

[RoutePrefix("api/instagram")]
publicclass InstagramSubscriptionController : ApiController
{
[Route("subscribe")]
public async Task<IHttpActionResult> PostSubscribe()
{
// Get our WebHook Client
InstagramWebHookClient client = Dependencies.Client;

// Subscribe to a geo location, in this case within 5000 meters of Times Square in NY
var sub = await client.SubscribeAsync(string.Empty, Url, 40.757626, -73.985794, 5000);

return Ok(sub);
}

[Route("unsubscribe")]
public async Task PostUnsubscribeAll()
{
// Get our WebHook Client
InstagramWebHookClient client = Dependencies.Client;

// Unsubscribe from all subscriptions for the client configuration with id="".
await client.UnsubscribeAsync("");
}

[Route("unsubscribe/{subId}")]
public async Task PostUnsubscribe(string subId)
{
// Get our WebHook Client
InstagramWebHookClient client = Dependencies.Client;

// Unsubscribe from the given subscription using client configuration with id="".
await client.UnsubscribeAsync("", subId);
}
}

Trying it Out!

Once you have deployed the project, you can attach the debugger to it and wait for somebody to post a picture within the geo location area. Of course, if you pick your own current location then you can post something to Instagram yourself as well.

To subscribe, send an empty https POST request using Fiddler or similar to a URI like below. Make sure that it is https as this is required by Instagram:

 
The result should look something like this:
 
{
"id": "20048438",
"object": "geography",
"object_id": "11286394",
"callback_url": "https://<host>.net/api/webhooks/incoming/instagram"
}

Depending on the location you subscribed to and the time of day you will of course get different results in how frequent images are posted. However, you should see something like this:
 
InstagramDebug
 
Once the notifications start flowing there is no end to what you may do with them. You could for example save the links to a data base and show them as part of your Web UI, or kick off some additional processing – the opportunities are open!

To unsubscribe, send an empty POST request to a URI like this:

 
Ok, that’s it – you can now subscribe to Instagram asking for notifications when images are posted within a specific geo location and use ASP.NET WebHooks to easily get the information about the posted images so that you can use them in your Web application.
 
Have fun!

Henrik

ASP.NET Community Standup - September 15, 2015

$
0
0

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:

After a few minutes discussing various IoT and minor hardware repair issues, Scott and Damian started off reviewing the week's news.

Damian reported that the team is halfway through the coding for the beta 8 milestone.  There is a LOT of work going on in beta 8, and he anticipates it being a large release.  There is an announcement on the announcements repository detailing the hosting changes with IIS and Kestrel starting in beta 8.  Briefly, this announcement covers the removal of Helios and focuses on the delivery of the WebListener and Kestrel hosts.  

Damian then reminded us that WebListener is built on the Windows http.sys module where Kestrel is bound directly to sockets and is completely made up of managed code that will run cross-platform.  The team is working on Kestrel performance, which admittedly needs help in Linux environments.  With the help of the community, the team has found and improved memory performance in the internals of the ASP.NET frameworks.  In particular, Damian highlighted work being done on memory pooling in the MVC and Razor frameworks.

The dnx -watch command has been committed to by the team.  This feature will allow dnx to recycle as code changes in your project.  Visual Studio developers have this feature in that Visual Studio will kill dnx and restart it as your code changes.

More cross-platform work is being done in globalization, networking, and crypto.  The Azure deployment story is a focus as well, with the team working on making the deployment better both inside and outside of Visual Studio.  The team is working on allowing csproj-based projects to reference xproj-based projects.

The team is building a new website to demonstrate running ASP.NET on Linux in Azure called go.asp.net  Another site being built is a new landing page for ASP.NET called get.asp.net that will have a "big green install button" that will help get development tools for ASP.NET.  More information about these two new sites will be made available as they are published.

Scott reported that he is working with a designer to rebrand www.asp.net and will coordinate with Damian to ensure that the same design makes it into go.asp.net and get.asp.net

Damian furthered that get.asp.net should also host an apt-get feed to make it easier for Linux developers to install ASP.NET tools.

Links of the Week:

Questions

Question: When will Glimpse be available for ASP.NET vNext?
They're working on it, with a preview available and hope to have a release in time for ASP.NET 5 RTM

Question: Would it be possible with TagHelpers to build an "each" attribute that will provide variables for inner-scope?
No... not for the current version, but is planned for a later version.  It requires interaction between the TagHelper and the compilation of the Razor view, and TagHelpers cannot interact at that level.  You can pass in to the TagHelper a state object that the TagHelper can interact with.

Question: Any word on gulp support for Azure website support for ASP.NET 5?
Gulp and Grunt are both installed by default in ASP.NET 5 and it works fine for Damian to deploy live.asp.net.

Question: Any information about Identity Server partnership?
Nothing new to report

Question: Is there a way to change the dnx install location from %UserProfile%/.dnx?
The team is revisiting this discussion, and is coordinating with NuGet in hopes to get this location shipped in beta 8

Question: Did you compare performance of Kestrel vs. WebListener?
We DID!  Kestrel is faster on matching hardware with pipelining enabled.  Since WebListener is built with http.sys which means every call is a system call and that impacts performance.  Kestrel has an optimized pipeline that reduces the number of system calls.  

Damian then diverted into a benchmarks discussion.  See github.com/aspnet/Benchmarks for details of the current benchmarks.   The fastest the team could push through raw http.sys on Windows was 460k requests/sec   That is with a minimum amount of native code, raw C++ calling http.sys in an exe.  By comparison, with libuv on top of C# with pipelining is 6x that amount.  When RIO is used, that amount goes up to 5.9M requests/sec.  There are additional numbers showing the performance of the host processes as frameworks are added, and it shows the team is making progress in boosting performance.

Question: Are you responsible for VS IDE issues with ASP.NET 5?
Yes, there is a tooling repo in the ASP.NET organization in GitHub - log issues there and the team will address it.

Question: Can you load the Razor engine dynamically and limit the assemblies that it can load?
Yes, Razor is a stand-alone component that can be loaded and hosted in another process.

Question: Will there be some AngularJS integration by default in ASP.NET 5 default templates?
Not sure.... there was some initial investigation in the MusicStore / SPA example as an exploration of server-side generation of Angular templates.  The team plans to circle back and spend time on it, but it is not known if that will become a default.

Summary:

Scott is visiting the office in Redmond this week and will be in Europe over the next few weeks.  Over the next few weeks, there will be some missed meetings.  Scott is working on determining how to delegate the creation and hosting of the meeting for future meetings when he may be unavailable.  The next meeting is scheduled for September 29th, tune in then to talk to the team and ask them your questions.

Viewing all 7144 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>