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

Announcing the Release of Web API OData 5.3

$
0
0

The NuGet packages for ASP.NET Web API OData 5.3 are now live on the NuGet gallery!

Download this release

You can install or update the NuGet packages for ASP.NET Web API OData 5.3 using the NuGet Package Manager Console, like this:

  • Install-Package Microsoft.AspNet.OData -Version 5.3.0
  • Install-Package Microsoft.AspNet.WebApi.OData -Version 5.3.0

What’s in this release?

This release primarily includes great new features for Web API OData v4 as summarized below:

ASP.NET Web API OData 5.3

Additional Documentation

Tutorials and other information about Web API OData are available from the ASP.NET web site (http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api).

Questions and feedback

You can submit questions related to this release on the ASP.NET Web API forums. Please submit any issues you encounter and feature suggestions for future releases on our CodePlex site.

Thanks and enjoy!


Announcing the 0.6.0-beta preview of Microsoft Azure WebJobs SDK

$
0
0

We are releasing another preview of the Microsoft Azure WebJobs SDK, which was introduced by Scott Hanselman. To read more about the previous preview, read this announcement post.

This release has the same general feature set as 0.5.0-beta as well as a few new exciting ones.

Download this release

You can download the WebJobs SDK from the NuGet gallery. You can install or update these packages from the NuGet gallery using the NuGet Package Manager Console, like this:

Install-Package Microsoft.Azure.WebJobs –Pre

If you want to use Microsoft Azure Service Bus triggers, install the following package:

Install-Package Microsoft.Azure.WebJobs.ServiceBus -Pre

What is the WebJobs SDK?

The WebJobs feature of Microsoft Azure Web Sites provides an easy way for you to run programs such as services or background tasks in a Web Site. You can upload and run an executable file such as an .exe, .cmd, or .bat file to your web site while running these as triggered or continuous WebJobs. Without the WebJobs SDK, connecting and running background task requires a lot of complex programming. The SDK provides a framework that lets you write a minimum amount of code to get common tasks done.

The WebJobs SDK has a binding and trigger system which works with Microsoft Azure Storage Blobs, Queues and Tables as well as Service Bus. The binding system makes it easy to write code that reads or writes Microsoft Azure Storage objects. The trigger system calls a function in your code whenever any new data is received in a queue or blob.

Updates in this preview

Table Ingress.

One of the offerings in the SDK is to bind to Azure Storage Tables. In this release the SDK allows you to Ingress data into Azure Tables. Ingress is a common scenario when you are parsing files stored in blobs and storing the values in Tables such as CSV readers. In these cases the Ingress function could be writing lots of rows (million in some cases).

The WebJobs SDK makes it possible to implement this functionality easily and allows add real time monitoring capabilities such as number of rows written in the table so you can monitor the progress of the Ingress function.

The following function show how you can write 100,000 rows into Azure Table storage.

Code Snippet
  1. publicstaticclassProgram
  2. {
  3.     staticvoid Main()
  4.     {
  5.         JobHost host = newJobHost();
  6.         host.Call(typeof(Program).GetMethod("Ingress"));
  7.                 }
  8.     [NoAutomaticTrigger]
  9.     publicstaticvoid Ingress([Table("Ingress")] ICollector<Person> tableBinding)
  10.     {
  11.         // Loop to simulate Ingressing lots of rows.
  12.         // You would replace this with your own logic
  13.         // of reading from blob storage and write to Azure Tables.
  14.         for (int i = 0; i < 100000; i++)
  15.         {
  16.             tableBinding.Add(
  17.             newPerson()
  18.             { PartitionKey = "Foo", RowKey = i.ToString(), Name = "Name" }
  19.             );
  20.         }
  21.     }
  22. }
  23. publicclassPerson
  24. {
  25.     publicstring PartitionKey { get; set; }
  26.     publicstring RowKey { get; set; }
  27.     publicstring Name { get; set; }
  28. }

When you run this function and view the function in the dashboard, you will the following snapshot. The dashboard will show in real time how many rows are written in the table called “Ingress”. Since this is a long running function the dashboard shows an “Abort Host” button which allows you to cancel a long running function.

IngressInProcess

When the Ingress function completes successfully, then the dashboard displays a success message as shown below.

IngressComplete

In the above example, the Ingress function was invoked through host.Call(). You can use this pattern to call this Ingress program on a schedule. You can also call the Ingress function when a new blob is uploaded in a container. For eg. if you have a background processing program which parses files stored in blob storage and writes the data into tables then you can do something like below:

Code Snippet
  1. publicstaticclassProgram
  2. {
  3. staticvoid Main()
  4. {
  5.     JobHost host = newJobHost();
  6.     host.RunAndBlock();
  7. }
  8. publicstaticvoid CSVParsing(
  9. [BlobTrigger(@"table-uploads\{name}")] TextReader input,
  10. [Table("Ingress")] ICollector<Person> tableBinding)
  11. {
  12.     // This is psuedo code showing how you can parse your CSV files
  13.     // and store them into Azure Tables
  14.     IEnumerable<Person> rows = ParseUsingMyCSVParser<Person>(inputStream);
  15.     foreach (var row in rows)
  16.     {
  17.         tableBinding.Add(row);
  18.     }
  19. }
  20. }
  21. publicclassPerson
  22. {
  23.     publicstring PartitionKey { get; set; }
  24.     publicstring RowKey { get; set; }
  25.     publicstring Name { get; set; }
  26. }

As a developer now you implement Ingress scenarios fairly easily and also get real time monitoring on the dashboard without having to write any diagnostics code yourself.

Apart from Ingress scenarios, you can also do the following with Azure Tables:

  • Read a single entity.
  • Enumerate a partition.
  • Bind to IQueryable/ IEnumerable to get a list of entities.
  • Create, Update and Delete entities.

Please see the following sample for more information: https://github.com/Azure/azure-webjobs-sdk-samples/tree/master/BasicSamples/TableOperations

Sending multiple messages on a queue.

Starting with this version, you can use ICollector.Add() to send multiple messages to a queue.

Note: In the previous version of the SDK you were using ICollection, which is removed. Please use ICollector going forward.

Another behavior change is now as soon as you do Add(), the SDK will write the message on a queue. In the previous version the SDK would wait until the function completed before it wrote all the messages to a queue.

The following code shows how you can send multiple messages to a queue.

Code Snippet
  1. publicstaticclassProgram
  2. {
  3. staticvoid Main()
  4. {
  5.     JobHost host = newJobHost();
  6.     host.RunAndBlock();
  7. }
  8. publicstaticvoid WriteMultipleQueueMessages(
  9. [QueueTrigger("queue")] string message,
  10. [Queue("outputqueue")]ICollector<string> output)
  11. {
  12.     // Process queue message and write multiple messages to the outputqueue
  13.     output.Add("message1");
  14.     output.Add("message2");
  15. }
  16. }

 

Samples

Samples for WebJobs SDK can be found at https://github.com/Azure/azure-webjobs-sdk-samples

    • You can find samples on how to use triggers and bindings for blobs, tables, queues and Service Bus.
    • There is a sample called PhluffyShuffy which is an Image processing Website where a customer can upload pictures which will trigger a function to process those pictures from blob storage.

Documentation

Deploying WebJobs with SDK to Azure Websites

Visual Studio 2013 Update 3 with Azure SDK 2.4 added Visual Studio Tooling support to publish WebJobs to Azure Websites. For more information, see How to Deploy Azure WebJobs to Azure Websites

Known Issues when migrating from 0.5.0-beta to 0.6.0-beta

ICollector instead of ICollection

In the previous version of the SDK you were using ICollection, which is removed. Please use ICollector going forward starting this release.

Another behavior change is now as soon as you do Add() in this case, the SDK will write the message on a queue. In the previous version the SDK would wait until the function completed before it wrote all the messages to a queue.

Give feedback and get help

The WebJobs feature of Microsoft Azure Web Sites and the Microsoft Azure WebJobs SDK are in preview. Any feedback to improve this experience is always welcome.

If you have questions that are not directly related to the tutorial, you can post them to the Azure forum, the ASP.NET forum, or StackOverflow.com. Use #AzureWebJobs SDK for Twitter and the tag Azure-WebJobsSDK for StackOverflow.

The Ajax Control Toolkit are now maintained by DevExpress

$
0
0

The open sourced Ajax Control Toolkit now has a new owner: DevExpress.  This project was created on codeplex in 2007 and our team has been sponsoring its development ever since.  It has been downloaded millions of times and played an important role in the field.  The ASP.NET team knows that many people use the ASP.NET Ajax Control Toolkit and that it continues to be updated to work with modern browsers. We are happy to announce that DevExpress has stepped up to be the project owner for the toolkit and is in the process of making sure it is easy to install, works with modern browsers and continues to get updates. We are thrilled to have them as  partner. Please see DevExpress’ announcement blog for more details.

ASP.NET vNext in Visual Studio “14” CTP 4

$
0
0

Today we released updates for ASP.NET vNext in Visual Studio “14” CTP 4. This release includes the ASP.NET vNext runtime and tooling improvements as outlined below.

ASP.NET vNext Runtime

This CTP includes our alpha4 runtime packages for ASP.NET vNext. You can find details on the specific enhancements added and issues fixed in the published release notes on GitHub.

For information on how to get started with ASP.NET vNext using Visual Studio “14” check out the article Getting Started with ASP.NET vNext and Visual Studio "14".

The MVC Music Store and Bug Tracker sample projects have been updated for this release. You can find instructions on how to open, build, run, and publish these sample ASP.NET vNext projects in the documentation in the corresponding GitHub repos.

There are a few notable breaking changes in this release from Visual Studio “14” CTP3:

  • Project.json now uses "aspnet50" and "aspnetcore50" as framework values, instead of "net45" and "k10".
  • Project.json has a new “webroot” element to indicate the static content folder and an “exclude” element for folders to be excluded from compilation.
  • The Startup.cs IBuilder parameter was renamed to IApplicationBuilder.

ASP.NET vNext Tooling

Performance improvements to compilation in Visual Studio

VS uses the Roslyn engine to compile ASP.NET vNext projects at design time. Therefore the project has already been compiled when you issue a “build” request. In Visual Studio “14” CTP4, VS simply passes the design time compiler output to the build request. This avoids another build and improves performance when you build, run, or debug ASP.NET vNext projects.

NuGet Package Manager support

Visual Studio now supports the NuGet Package Manager and console for ASP.NET vNext projects.

image_thumb[10]

To use this UI for upgrading current alpha ASP.NET vNext packages, click the Settings button and add package sources from developing sources:

New layout for ASP.NET vNext solutions and projects

ASP.NET vNext solutions created in project template now has a new project layout. While this new layout is not required, it helps with cleanly separating your application source code from other artifacts in your solution. New solutions now contain a <solutionFolder>\src folder for your application projects. A top level global.json file indicates the src folder can be used for looking up project references. This makes it easy to separate test code under a different folder, but still be able to reference application projects from your test projects. For test projects, we recommend to put them under <solutionFolder>\test directory. 

ASP.NET vNext web project template also puts static contents under the wwwroot folder that is determined by the webroot element of project.json.

image_thumb[3][4]

Global.json file in new solutions for project-to-project references

In the previous picture, you can see a global.json file in the same level as the solution file, to make better support for project-to-project references. It contains “sources”: [“src”] element, indicating the “src” folder as the parent folder for looking for project references.

By default, project-to-project references lookup will use parent directory, plus the global.json-defined directories. For example, we have the following solution structure and project.json dependency visibility:

Solution1\global.json

content {“sources”: [“src”] }

Solution1\src\WebApp1

Possible Dependencies: ”ClassLib1” :””

Solution1\src\ClassLib1

Possible Dependencies: ”WebApp1” :””

Solution1\test\TestProj1

Possible Dependencies: ”WebApp1” :””, ”ClassLib1” :””, ”TestProj2” :””

Solution1\test\TestProj2

Possible Dependencies: ”WebApp1” :””, ”ClassLib1” :””, ”TestProj1” :””

We only need two simple steps to add an ASP.NET vNext class library reference to the default ASP.NET vNext web application.

1. In Solution Explorer, add a new project under the “src” folder. Note, we need to append the “src” folder to the “Add New Project” Location edit box manually at this time. (VS will do this automatically in a future release.)

image_thumb[4]_thumb

2. Open web project’s project.json file, add “ClassLibrary1”:”” inside the “dependencies” element

image_thumb[6][1]

Debugging support for ASP.NET vNext unit tests

In VS “14” CTP3, support was added for running xUnit.NET tests in the VS Test Explorer tool window. VS “14” CTP4 now supports debugging tests from the tool window as well.

image_thumb[8][1]

Immediate refresh of the Project References node for project.json dependency changes

In this release, we enhanced ASP.NET vNext project References node behavior to immediately reflect project.json file dependency changes, while the package checking and loading happens in the background.

Known Issues

1. There are some known tooling issues with the new solution structure, which you need to be careful about, especially when adding project-to-project references:

    • When you create a new ASP.NET vNext project, an empty project folder is created under the solution folder. This folder should be removed, because the real project folder is created under <solutionFolder>\src subfolder.
    • In an ASP.NET vNext project, when you right-click the solution "src" folder or solution node, and add a new project to it (say ClassLibrary1), the Add New Project file dialog uses the solution folder as the location, instead of the "src" location. Project-to-project references will not work properly at runtime as a result.

clip_image011_thumb[1]_thumb

To work around the problem, you need to add “.” (current folder) to the list of project folders specified in global.json : "sources": [ "src", "." ], or move the project folder to the “src” folder manually.

2.  With the new solution structure, you will run into some issues if you uncheck the ‘Create directory for solution’ checkbox in the File > New Project dialog. Due to some quirks in the way this checkbox is handled internally, if you specify a custom location for your projects in the New Project dialog (e.g.: C:\Tests instead of using the default path provided by VS), you will find that projects in the src folder still get created in the default projects path rather than under the custom path that you provided.

3. On Windows 8 RTM, pressing F5 in an ASP.NET vNext project does not work for the Core CLR framework. Ctrl + F5 works fine. Pressing F5 works fine for core CLR framework on Windows 8.1.

4. Three Core CLR package versions were downgraded due to a restructure of the Core CLR packages.  If you installed VS “14” CTP4 on a machine that you’ve already used ASP.NET vNext on before, clear out %userprofile%\kpm\packages to ensure projects can successfully build and run. They are:

  • System.Text.Encoding from 4.0.20.0 to 4.0.10.0
  • System.IO.FileSystem from 4.0.10.0 to 4.0.0.0
  • System.IO.FileSystem.Primitives from 4.0.10.0 to 4.0.0.0

Summary

We’d love to hear your feedback. For Visual Studio tooling related issues, please submit bugs through Connect, send suggestions on UserVoice and quick thoughts via Send-a-Smile in the Visual Studio IDE. For ASP.NET vNext, please provide feedback in GitHub or the ASP.NET vNext forum. If you ask a question in Stack Overflow, use the asp.net-vnext tag.  Thanks for being with us in this exciting time!

Where can you meet the team? November 2014 at AngleBrackets and TechEd

$
0
0

We on the Web Tools team love hanging out with the community. We thought it would be cool to start sharing exactly where we will be and what conferences or user groups you can join us at!

The .NET Developer Blog has a great always updated list of .NET User Groups, so be sure to bookmark that also!

We’ve got two big events coming up soon, and there is still time to register!

  • AngleBrackets Nov 10th-13th in Vegas is an exciting open-source web conference that’s collocated with DevIntersections. That means you can register for one and attend both! Come see All the Lesser Scotts (Hanselman and Hunter) as well as Scott Guthrie, along with industry luminaries like Kathleen Dollard and K. Scott Allen!
  • TechEd Europe is in Spain this year Oct 28th-31st and if you’re in or around Europe, you deserve a Spanish vacation. Join Scott Hunter, Pranav Rastogi, and Brady Gaster talking all things web this year in Barcelona.

We’ll post to the this blog each month with our list of exciting events. Make sure you’ve subscribed!

_references.js file’s auto sync feature

$
0
0

In VS2013 RTM, we shipped a not well known feature for _references.js file: /// <autosync enabled="true" />.

If we specify /// <autosync enabled="true" /> in the beginning of ~/scripts/_references.js, then any addition, rename, deletion of JavaScript files in the project will automatically change the content in this file. You can disable this feature by removing the line or put assign false to enabled attribute.

For example, create a new MVC project, open scripts/_references.js file and you will see the following if you are using VS2013 with update 3.

clip_image001

Drag and drop bootstrap.js file to the Scripts folder to make a copy, and all the missing “.js” files and the newly added “.js” files are automatically referenced in the _references.js file. Note, we ignore the “.min.js” files if the non-minified “.js” file exists.

clip_image003

You can enable and disable the auto sync feature via editor’s context menu button “Auto-sync JavaScript References”. You can always manually update the project’s JavaScript references using the context menu button “Update JavaScript References”.

clip_image004

For more details in _references.js, please visit Mads’ blog The story behind _references.js.

Announcing Microsoft.ASPNET.Facebook 1.1 RTM

$
0
0

The NuGet packages for Microsoft.ASPNET.Facebook 1.1 are now live on the NuGet gallery!

Download this release

You can install or update the NuGet packages for Microsoft.ASPNET.Facebook 1.1 using the NuGet Package Manager Console, like this:

  • Install-Package Microsoft.AspNet.Facebook –Version 1.1.0

What’s in this release?

In this release, we enabled better support for the Safari browser and added a new feature that gives developers the ability to add custom logic for browsers that do not have cookies enabled. You can find detailed explanation for the new features here.

The Visual Studio template that uses this updated package will be released soon. The Visual Studio Facebook 1.0 template can be found here.

Announcing new Web Features in Visual Studio 2013 Update 4 RC

$
0
0

Today, the Visual Studio team announced the release of Visual Studio 2013 Update 4 RC.  Our team added a few useful features and did some bug fixing in this update to improve the web development experience.

Microsoft ASP.NET and Web Tools 2013.4 RC

JSON Editor Improvement

We made a few improvements in the JSON editor, including performance improvements such as loading the JSON schema asynchronously, caching child schemas, improving IntelliSense, etc. We also have the following new features:

JSON Schema validation

We added a JSON schema validation feature, based on the schema selected in the drop-down list.

clip_image001[5]

Un-minify context menu button

You can right-click the JSON editor and select Un-minify context menu button to un-minify any long arrays in the JSON file.

For example, un-minify the following JSON content.

clip_image002[5]

You will get the following:

clip_image003[5]

In contrast, formatting document using formatting menu command or “Ctrl-K,Ctrl-D” will keep the original array format:

clip_image004[5]

Reload Schemas context menu button

VS will cache the schema downloaded from internet and will use the cache even after you restart VS. If you know the schema has changed, you can use the context menu “Reload Schemas Ctrl+Shift+J” to re-download the current selected schema in the active JSON document, and use it immediately for the current document.

HTML Editor

We improved the HTML editor with some bug fixes, updated IntelliSense for web standards, and introduced the following new features.

Better client template formatting

The HTML editor is not parsing or formatting the double-curly syntax {{…}} any more. That makes sure that we don’t treat the content of those curlies as being HTML and therefore not invalidating them, nor try to format them which we can’t do correctly using the HTML formatter. This is great for Angular, Handlebars, Mustache and other double-curly template syntaxes.

Support for custom elements, polymer-elements and attributes

We no longer validate unknown attributers for custom elements as there will be many custom made tags in different frameworks. So there will no longer be squiggles under the unknown elements.

clip_image005[5]

Basic IntelliSense for Web Components

We have IntelliSense for <link rel=”import” /> which is part of the Web Components standard.

HTML element tooltips

We now supply tooltips for HTML elements in the editor.

clip_image007

#region support

HTML editor now supports region folding. You can use a surrounding snippet to surround the current selection as well.

clip_image008

TODO/Hack/etc. comment support in HTML pages in Task List

We now display Todo, Hack etc comment token from HTML pages to the TaskList.

clip_image009[5]

CSS/LESS/Sass Editor

We improved CSS/LESS/Sass editor with some bug fixes, updated IntelliSense for web standards, improved the selectors level 4 IntelliSense, and introduced the following new features.

Todo/Hack/etc. from CSS/LESS/Sass editor comment support in Task List

We now display Todo, Hack etc comment token from CSS/LESS/Sass pages to the TaskList.

clip_image010[5]

@viewport fix for LESS editor

In LESS editor, @viewport will not show verification warnings any more. E.g.:

@viewport { width: device-width; } 

Many more snippets

We now provide more snippets to ease the developing experience.

clip_image011[5]

Browser Link

CSS auto-sync

Now, saving the CSS file or changing it externally (like with a LESS/SASS compiler) will cause the whole CSS file to reload in the browser. If the file was in a state where it couldn’t auto-sync, Ctrl+S will cause an automatic reload that should put it back in a good state, without needing to refresh the linked browsers(Ctrl+Alt+Enter). The feature can be disabled in the toolbar.

clip_image012[5]

WebJobs Tooling

We now support controlling WebJobs through the Server Explorer WebJobs node inside Azure Websites.

WebJobs node underneath Website node in Server Explorer

clip_image013[5]

Start/Stop and debug WebJobs from Server Explorer

clip_image014[4]

Run On -demand or Scheduled jobs from Server Explorer

clip_image015[5]

View WebJobs Dashboard from Server Explorer

You can use “View Dashboard” context menu to go to the Azure website’s WebJobs dashboard, as shown in the above screenshots.

WebJobs SDK

The WebJobs SDK is pre-installed in the Azure WebJob project templates

As before, you can create a new WebJob project using the “Azure WebJob” project template.

image_thumb[52]

The generated file will contain a package.config with following content:

<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Microsoft.Azure.WebJobs" version="1.0.0" targetFramework="net45" /> <package id="Microsoft.Azure.WebJobs.Core" version="1.0.0" targetFramework="net45" /> <package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net45" /> <package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net45" /> <package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net45" /> <package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" /> <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" /> <package id="System.Spatial" version="5.6.0" targetFramework="net45" /> <package id="WindowsAzure.Storage" version="4.2.1" targetFramework="net45" /> </packages>

 

ASP.NET MVC 5.2.2

Template packages are updated to use ASP.NET MVC 5.2.2. This release doesn’t have any new features or bug fixes in MVC. We made a change in Web Pages for a significant performance improvement and have subsequently updated all other dependent packages we own to depend on this new version of Web Pages.

ASP.NET Web API 5.2.2

In this release we have made a dependency change for Json.Net 6.0.4. For information on what is new in this release of Json.NET, see Json.NET 6.0 Release 4 - JSON Merge, Dependency Injection. This release doesn’t have any other new features or bug fixes in Web API. We have subsequently updated all other dependent packages we own to depend on this new version of Web API.

ASP.NET Web API OData 5.3.1 beta

Please see this release note for Web API OData 5.3 and 5.3.1 beta.

SignalR 2.1.2

Template packages are updated to use SignalR 2.1.2. Please see its release note on GitHub.

Owin 3.0

Template packages are updated to use Owin 3.0 NuGet packages. Please see this Owin 3.0 release note.

Summary

We hope you can evaluate these new features and let us know about any bugs and suggestions.  For VS features, please use Connect to submit bugs, ASP.NET UserVoice to submit and vote for suggestions, and the ASP.NET Forums for Q&A.  You can also visit the following open source sites to leave suggestions and open issues directly:


Microsoft Asp.Net MVC Security Update MS14-059 broke my build!

$
0
0

Microsoft just released a new security update to be automatically applied to machines configured to use Microsoft Update.  The security bulletin is available here: https://technet.microsoft.com/en-us/library/security/ms14-059

Unfortunately, some ASP.NET MVC 3 and 4 VS projects can no longer build after the update is applied. These projects will fail with the following error:

 Could not locate the assembly "System.Web.Mvc,Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL".

This happens when your project references assemblies from the GAC or the Reference Assemblies folder. Project references to System.Web.Mvc.dll are no longer resolved because the assembly version of System.Web.Mvc.dll was incremented. 

The problem can be resolved by implemented one of the following solutions:

  1. (Preferred) Install Microsoft.AspNet.Mvc from the NuGet gallery (this will install a binding redirect in your web.config).  You can do this from the NuGet package manager or the NuGet console inside Visual Studio:

    >Install-Package Microsoft.AspNet.Mvc -Version <version> -Project PROJECTNAME

    MVC 4 version: 4.0.40804.0

    MVC 3 version: 3.0.50813.1

  2. Manually update the reference to System.Web.MVC.dll (don’t use the one in the GAC).

    Try the Add Reference -> Assemblies -> Extensions dialog box. 

In either case ensure that the CopyLocal project property for the assembly is set to true so it ends up in your bin folder which is needed for deployment. There is a known NuGet bug that resets the CopyLocal flag: https://nuget.codeplex.com/workitem/4344

For MVC projects built prior to VS 2012 references to MVC assemblies were added from either the GAC or the Assembly References folder.  Most recent MVC templates add references to assemblies installed via NuGet packages, this is why option No.1 above is preferred.  The NuGet gallery has become very popular.

As a side note, a similar issue may occur when creating a new MVC 3 project in Visual Studio 2010, this is documented in the security bulletin:

MVC 3.0 RTM is installed on my system and after installing the update I can no longer create a new project in Visual Studio 2010, how can I correct this? 
ASP.NET MVC 3.0 templates for Visual Studio 2010 rely on assemblies that are installed in the Reference Assemblies folder. Since the updated version of the assembly for MVC 3.0 is incremented, templates will no longer work. To solve this problem, install the MVC 3.0.1 tooling refresh for Visual Studio 2010. 

Finally, the decision to increment the assembly version was to secure those applications that were deployed on servers owned by third parties, in this case the vulnerable assembly may be in the GAC. In order to ensure the application runs the secure assembly, the assembly version had to be incremented.

ASP.NET Identity 2.2.0-alpha1

$
0
0

We are releasing a preview of ASP.NET Identity 2.2.0-alpha1. The main focus in this release was to fix bugs and address performance issues.

Download this release

You can download ASP.NET Identity from the NuGet gallery. You can install or update these packages using the NuGet Package Manager Console, like this:

Install-Package Microsoft.AspNet.Identity.EntityFramework–Version 2.2.0-alpha1 -pre 

Install-Package Microsoft.AspNet.Identity.Core -Version 2.2.0-alpha1 -pre

Install-Package Microsoft.AspNet.Identity.OWIN -Version 2.2.0-alpha1 –pre

What’s in this release?

Following query has the list of all issues fixed in this release..

Samples/ Documentation

Migrating from ASP.NET Identity 2.1.0

This is a compatible release with 2.1.0 and there are no database schema changes with this release.

Give feedback and get support

    • If you find any bugs please open them at our Codeplex Site where we track all our bugs https://aspnetidentity.codeplex.com/
    • If you want to discuss these features or have questions, please discuss them on Stack Overflow and use the following tag “asp.net-identity”

Where can you meet the team? November 2014 at AngleBrackets and Connect();

$
0
0

We’ve got two big events coming up next week. 

AngleBrackets

Nov 10th-13th in Vegas is an exciting open-source web conference that’s collocated with DevIntersections. That means you can register for one and attend both! Come see Scotts Hanselman and Scott Guthrie, along with web tooling PM Mads Kristensen and Mohit Srivastava , and industry luminaries like Kathleen Dollard and K. Scott Allen!

Connect();

Starting on Wednesday, November 12, join industry leaders Scott Guthrie, S. "Soma" Somasegar, Brian Harry, and Scott Hanselman live from New York as they share insights about new technologies and features coming to .NET, ASP.NET, Azure, Visual Studio, and Visual Studio Online. They'll be joined on stage with demos from subject matter experts, Amanda Silver, Jay Schmelzer, Daniel Moth, and Brian Keller. Afterwards, engage in live, interactive Q&A sessions with the keynote speakers before jumping into the technical details with over 40 on-demand technical sessions.

Come back on Thursday, November 13, to interact with engineering team members in live sessions from the Microsoft Campus in Redmond, WA and gain further insight about the newest tools, frameworks, and services.

Enjoy!

Dialog box may be displayed to users when opening projects in Microsoft Visual Studio after installation of Microsoft .NET Framework 4.6

$
0
0

After the installation of the Microsoft .NET Framework 4.6, users may experience the following dialog box displayed in Microsoft Visual Studio when either creating new Web Site or Windows Azure project or when opening existing projects.

Configuring Web http://localhost:64886/ for ASP.NET 4.5 failed. You must manually configure this site for ASP.NET 4.5 in order for the site to run correctly. ASP.NET 4.0 has not been registered on the Web server. You need to manually configure your Web server for ASP.NET 4.0 in order for your site to run correctly.

NOTE: Microsoft .NET Framework 4.6 may also be referred to as Microsoft .NET Framework 4.5.3

This issue may impact the following Microsoft Visual Studio versions: Visual Studio 2013, Visual Studio 2012, Visual Studio 2010 SP1

Workaround:

Select “OK” when the dialog is presented. This dialog box is benign and there will be no impact to the project once the dialog box is cleared. This dialog will continue to be displayed when Web Site Project or Windows Azure Projects are created or opened until the fix has been installed on the machine.

Resolution:

Microsoft has published a fix for all impacted versions of Microsoft Visual Studio.

Visual Studio 2013 –

Visual Studio 2012

  • An update to address this issue for Microsoft Visual Studio 2012 has been published: KB3002339
  • To install this update directly from the Microsoft Download Center, here

Visual Studio 2010 SP1

  • An update to address this issue for Microsoft Visual Studio 2010 SP1 has been published: KB3002340
  • This update is available from Windows Update
    • To install this update directly from the Microsoft Download Center, here

New Developer and Debugging Features for Azure WebJobs in Visual Studio

$
0
0

With Visual Studio Update 3, the Web Tools Extensions team added a number of great features to make it easier for ASP.NET developers publishing web applications to Azure Websites to enable background processing using Azure WebJobs. Since the Update 3 release, Azure WebJobs has reached general availability, and to coincide with the release of Azure WebJobs we've added more features to Visual Studio to make it easier than ever to build, deploy, and debug WebJobs. This blog post will introduce you to some of the new features for developers who want to create, deploy, and debug Azure WebJobs. Through a simple walk-through of getting an ASP.NET site enabled with a pair of Azure WebJobs, you'll learn how to get started without even leaving Visual Studio.

Adding WebJobs to an Existing ASP.NET Web App

To start this demonstration, I've created a bare-bones ASP.NET MVC Web Site using Visual Studio 2013. WebJobs can be added to any existing ASP.NET application. Likewise, the Azure SDK includes project templates for creating WebJobs without the need for an existing ASP.NET application. WebJobs can be deployed either as part of an existing ASP.NET web project, or they can be deployed to Azure Websites directly via a simple project-level context menu item.

clip_image001

I'll right-click the Web Application Project node in Solution Explorer, expand the Add context menu, and select the New Azure WebJob Project context menu item from the fly-out. This will drop a new Azure WebJob project into my existing Visual Studio solution. If I'd had an existing Console Application or WebJobs project sitting on disk, I could have selected the Existing Project as Azure WebJob context menu instead, which would allow me to browse my local computer to find an existing project.

clip_image002

When I select the New Azure WebJob Project context menu item, the Add Azure WebJob dialog opens. Using this dialog, I'll specify that I want this first WebJob to be a Continuous one. I'll give the Project and WebJob a name, and click the OK button.

clip_image003

With Visual Studio Update 4 or the Azure SDK 2.5, I'll have two project templates to choose from based on the run mode of my WebJob. Since I've selected Continuous for this first WebJob, the code dropped into the project will be specific to a continuous scenario.

Once the project is added to my solution, I'll open up the Program.cs file from the project. The code in this file uses the WebJobs' JobHost object to start up the WebJob and block it from exiting. This will allow the continuous WebJob to remain in memory so that it can monitor an Azure Storage Queue for incoming messages.

clip_image004

Included along with the Program.cs file that launches my WebJob is a second file containing boilerplate code that uses the WebJobs SDK to watch an Azure Storage Queue. The code below, from Functions.cs, demonstrates how the QueueTrigger attribute is used to define a method parameter as one that will be populated when messages land on the Storage Queue being watched by the code. For more information on the various attributes available for monitoring Queues, Blobs, or Service Bus objects, take a look at the long list of WebJobs SDK resources available on ASP.NET.

clip_image005

I'll follow the same process again to add a second WebJob to the ASP.NET project. This time I'll select Run on Demand from the Run Type menu. This WebJob will be one that doesn't run continuously or watch Azure Storage Queues, but rather, will run only when a user elects to run the WebJob from within Visual Studio or from the Azure Management Portal.

clip_image006

The code for scheduled and on-demand WebJobs is slightly different from the code dropped in for continuous WebJobs. The Program.cs code for an on-demand job, shown below, doesn't block the WebJob's EXE from exiting. Instead, it presumes a one-time run is needed, and then the WebJob simply exits.

clip_image007

The code below, from the on-demand WebJob project, simply has a method in it named ManualTrigger that drops a message into an Azure Storage Queue using the Queue attribute decorating the final method parameter. When the value of this out parameter is set in the second line of the method, a new Azure Storage Queue message is dropped into the queue so that it can be processed by the first WebJob, which is running continuously and watching the queue for incoming messages.

clip_image008

The idea is simple - the first WebJob is running continuously, watching an Azure Storage Queue for incoming messages, whereas the second WebJob will be executed manually to drop messages into the Azure Storage Queue being watched.

Simultaneous Web Site and WebJob Publishing from Visual Studio

Now that the site is ready and armed with both on-demand and continuous WebJobs for background processing, the site and the WebJobs can easily be published with one context-menu click. The WebJobs tooling knows, at this point, that the two WebJob projects should be published along with the Web Application Project's content files.

clip_image009

Since I'll be publishing my Web Application with WebJobs, I'll need to select Microsoft Azure Websites when asked what my publishing target will be.

clip_image010

Since I don't yet have a destination Website running in Azure to which my Web Application Project can be deployed, I'll click the New button in the Select Existing Website dialog.

clip_image011

I'll give the site a name and select the appropriate region for it to be published into.

clip_image012

To enable remote debugging of my Website and Azure WebJobs, I'll select Debug from the Configuration drop-down menu.

clip_image013

During the publish preview, take note that the WebJobs are going to be published along with the Website contents. Since WebJobs run from the App_Data folder of an existing Website, I can see the two WebJobs' content in the Publish Preview dialog.

clip_image014

Azure WebJobs make use of Azure Storage for passing messages through queues and for storing or retrieving files from Azure Blob containers. In addition, the WebJobs Dashboard makes use of Azure Storage to store up statistics about how and when the WebJobs are executed. To reap these benefits, I'll need to configure the host Azure Website with the Storage Account connection string for my WebJobs storage and dashboard.

Configuring the WebJobs Connection String

Luckily, the Azure SDK for Visual Studio gives me easy accessibility to my Azure Storage accounts within the Visual Studio Server Explorer. By right-clicking on the Storage node of the Server Explorer, I can easily create a new Azure Storage Account using the context menu.

clip_image015

When I click the Create Storage Account context menu item, the Create Storage Account dialog opens, providing an opportunity to specify the Storage Account's name that I'd like to create. I'll also select the same region that will house my Azure Website, placing both the Website and the Storage Account into the same geographical region.

16-storage-account-creation

Once the storage account has been created I'll right-click on it to get the storage account properties.

clip_image017

When the properties panel opens, I'll click the ellipse button next to the Connection String property in the panel.

clip_image018

The Storage Account Connection String dialog will open, providing me an opportunity to copy the Storage Account's connection string to my clipboard.

clip_image019

Now I'll create two connection strings to configure WebJobs' connectivity in my Website named AzureWebJobsStorage and AzureWebJobsDashboard, and I'll paste in the connection string I copied earlier as the value of the connection string. The final step is to select Custom from the Database Type column in the Website Settings panel.

clip_image020

Now that the Web Application and WebJobs are published and configured, I’ll use the new Server Explorer tools for WebJobs and the remote debugging features to make sure everything is operating properly.

Managing and Debugging WebJobs using the Server Explorer

Now that the Web Application Project and accompanying WebJobs have been deployed, I'm going to want to debug into my continuous job to make sure it is working as expected and designed. To get a deeper dive into how the WebJob is executing, I'll set a breakpoint in the continuous job's code.

clip_image021

Some of the WebJobs-related features we're most proud of are visible in the Server Explorer. Underneath each Website node in Server Explorer, we've added a folder grouping to all of the associated WebJobs. To make the jobs easier to locate in the tree we've grouped them by continuous and on-demand or scheduled. We've hung various context menu items from the WebJobs nodes' context menu that are appropriate for the type of WebJob being clicked. I'll use the Start menu gesture from the continuous WebJob node to start up my continuous WebJob.

clip_image022

Now that the WebJob has been started, I'll use the Attach Debugger menu item to attach the Visual Studio debugger to the WebJob running in Azure. Once I click this menu item, Visual Studio will attach to the remote debugger running in Azure Websites, and attach the debugger to the WebJob's EXE.

clip_image023

Once the Continuous WebJob is running and the debugger attached, I can use the Scheduled/On-demand WebJob context gesture to start the on-demand job, which will send a message into the Azure Storage queue my Continuous WebJob is watching. The on-demand job will wake up and drop a message into the Azure Storage Queue.

clip_image024

Once the on-demand job drops a message into the Azure Storage queue being watched by the continuous WebJob and the message is picked up and processed by the WebJobs SDK, the contents of the message is visible in the debugger's watch window. Even though the code for my WebJob is actually running live in Azure, I'm able to debug the code locally within Visual Studio from my development workstation, giving me a deep level of visibility into how the WebJob code is executing in the cloud!

clip_image025

With the Visual Studio Update 4 and Azure SDK 2.5 releases we've greatly expanded our investment into making it easier than ever before for web developers to add background processing to their Websites. We've taken steps toward providing a greater level of control over the WebJobs running in an Azure Website, and we've provided deeper diagnostics and debugging features so that developers have great visibility into how their code is running in Azure. We hope you enjoy these new features and that you learn more about what's available in the Azure WebJobs SDK to extend this functionality. Have fun adding background processing to your ASP.NET Web Applications with Azure WebJobs!

Announcing ASP.NET features in Visual Studio 2015 Preview and VS2013 Update 4

$
0
0

Today we released both Visual Studio 2015 Preview and VS2013 Update 4. The ASP.NET team provided many new features and updates to both the runtime and tooling in Visual Studio 2015 Preview, including:

ASP.NET 5 Preview runtime

This release of Visual Studio supports creating and developing ASP.NET 5 Preview applications. ASP.NET 5 Preview is a lean and composable .NET stack for building modern web applications for both cloud and on-premises servers. It includes the following features:

  • ASP.NET MVC and Web API, which have been unified into a single programming model.
  • A no-compile developer experience.
  • Environment-based configuration for a seamless transition to the cloud.
  • Dependency injection out-of-the-box.
  • NuGet everything, even the runtime itself.
  • Run in IIS, or self-hosted in your own process.
  • All open source through the .NET Foundation, and takes contributions in GitHub.
  • ASP.NET 5 runs on Windows with the .NET Framework or .NET Core.
  • .NET Core is a new cloud optimized runtime that supports true side-by-side versioning.
  • ASP.NET 5 runs on OS X and Linux with the Mono runtime.

Visual Studio 2015 Preview includes Beta1 runtime packages for ASP.NET 5. You can find all the details for the specific enhancements added and issues fixed in the published release notes on GitHub.

Here are some helpful links to get you started with ASP.NET 5 Preview:

ASP.NET 5 Preview tooling features

To optimize ASP.NET 5 Preview project development experiences in Visual Studio, we created new Visual Studio features including new templates, a new project system, combined IntelliSense to support multi-framework targeting, and an updated NuGet package manager.

Templates

ASP.NET 5 templates

The "ASP.NET 5 Empty" and "ASP.NET 5 Starter Web" templates are added to "New ASP.NET Project" dialog for C#.

The "ASP.NET 5 Class Library" and "ASP.NET 5 Console Application" templates are added to "New Project" dialog under "Visual C#"/Web.

ASP.NET 5 templates use a new project structure

The ASP.NET 5 project structure contains a project.json configuration file, and ".kproj" project file. ASP.NET 5 project templates uses a new project layout, creating a project folder under <solutionFolder>\src, and use the global.json file to specify the project reference folder.

Global.json file contains "sources": ["src"] element, indicating the "src" folder as the parent folder of project references. By default, project-to-project reference lookups will use the parent directory, plus the global.json-defined directories. For example, we have the following solution structure and project.json dependency visibility:

Solution1\global.json

Content: {" sources": ["src"] }

Solution1\src\WebApp1

Possible Dependencies: "ClassLib1 " : ""

Solution1\src\ClassLib1

Possible Dependencies: "WebApp1" : ""

Solution1\test\TestProj1

Possible Dependencies: "WebApp1" : "", "ClassLib1 " : "", "TestProj2 " : ""

Solution1\test\TestProj2

Possible Dependencies: "WebApp1" : "", "ClassLib1 " : "", "TestProj1 " : ""

The ASP.NET 5 Application template contains the target frameworks "aspnet50" and "aspnetcore50"specified in project.json. They display as "ASP.NET 5.0" and "ASP.NET Core 5.0" under the solution explorer's References node.

The ASP.NET 5 web project template

The ASP.NET 5 web project template contains a layout to optimize for both static content and for package restore from NPM and Bower. The template puts static contents under the wwwroot folder that is determined by the webroot element of project.json.

"ASP.NET 5 Starter Web" template contains bower.json to use with Bower to get frontend packages, package.json to use with NPM to get Grunt, and gruntfile.js to manage tasks defined by project.json scripts. The template's project.json file contains "postrestore" and "prepare" scripts to use NPM, as well as Grunt and Bower to install necessary packages to the project during build. It also uses the "packExclude" element to define the folders and files that should be excluded during "KPM pack".

The ASP.NET 5 Starter Web template and EF

The ASP.NET 5 Starter Web template contains the code first migration for Entity Framework 7.0.0-beta.

You can use the k command from the command line to perform an Entity Framework code first migration if you specified "ef" : "EntityFramework.Commands" as the file project.json's commands element. For example:

    "k ef migration" from command line returns the following:

Usage: ef migration [options] [command]

Options:

-h|--help Show help information

Commands:

add Add a new migration

apply Apply migrations to the database

list List the migrations

script Generate a SQL script from migrations

    Sample commands can be:

        k ef migration add MyMigrationWithOnly1ContextInCode

k ef migration add MyMigration --context MyContext

        k ef migration script --context MyContext

        k ef migration apply --context MyContext

"ASP.NET 5 Starter Web" template and command line scaffolding

You can use command line scaffolding the ASP.NET 5 Start Web template because "gen":"Microsoft.Framework.CodeGeneration"is specified in project.json's commands element.

Projects and Builds

Project file no longer includes project directory items and references

ASP.NET 5 projects uses the <projectName>.kproj file as Visual Studio's project file. The .kproj file doesn't include any files from the current directory or sub-directories, as Visual Studio automatically includes and monitors the ASP.NET 5 project directory files.

Project.json file is used to define project information

Visual Studio uses the project.json file for reference and package dependencies, version definitions, framework configurations, compile options, build events, package creation meta-data, and run commands, as well as other details. This way, the project can be edited and run in Linux and on MacOS machines that do not have Visual Studio.

Dependencies node for Bower and NPM dependencies

Solution Explorer for ASP.NET 5 Web Applications has a Dependencies node showing Bower and NPM dependencies. The Bower dependencies are from bower.json in the project folder. The NPM dependencies are from package.json in the project folder.

In the Dependencies node, under the Bower and NPM's package nodes, you can uninstall a package through the context menu command, which will automatically remove the package from the corresponding JSON file.

References node displays all frameworks defined in project.json file

In the Solution Explorer of an ASP.NET 5 Application, the References node displays all frameworks defined in the project.json file.

Project's property page can be used to define runtime information

The ASP.NET 5 Application's Property Page is a tool window and can be used to specify the KRE target version, the debug target, and whether binaries and NuGet packages should be created during a Visual Studio build.

Fast build time with Visual Studio

Visual Studio uses the Roslyn engine to compile ASP.NET 5 projects at design time. Therefore, the project has already been compiled when you issue a "build" request. In Visual Studio 2015 Preview, Visual Studio simply passes the design time compiler output to the build request. This avoids another build and improves performance when you build, run, or debug ASP.NET 5 projects.

Support NuGet Package Manager

Visual Studio supports the NuGet Package Manager and the NuGet Package Console for ASP.NET 5 projects.

Support xUnit tests in Test explorer

Visual Studio supports running and debugging for ASP.NET 5 xUnit tests through test explorer. All you need to do is add the xUnit dependencies and test commands to the test project's project.json file, as shown below (NOTE: To install the xUnit packages you will need to add https://www.myget.org/F/aspnetvnext/api/v2 as a NuGet package source):

"dependencies": {

"Xunit.KRunner": "1.0.0-beta1"

},

"commands": {

"test": "Xunit.KRunner"

},

From the command line, you can use k test to get the running result, where k.cmd is from the current targeting K Runtime Environment.

Support Task Runner Explorer

Task Runner Explorer is integrated to Visual Studio, which can be enabled by selecting the gruntfile.js file's context menu item Task Runner Explorer, or via Visual Studio's menu-item View->Other Windows->Task Runner Explorer.

IntelliSense and Error list

We give combined IntelliSense when showing IntelliSense in the code editor. An IntelliSense item that exists in one framework, but not in another will be listed in the IntelliSense with a warning sign. The IntelliSense tooltip indicates which framework supports it and which framework doesn't.

Build errors shows which target framework the error is from. So, if you have an error in the code that is recognized by two targeting frameworks, it will show in two places in the error and output error list, with the same description and file location, but with different project names which includes the framework name.

NuGet Package Manager

The NuGet Package Manager is rewritten using the tool window style and can be viewed per project and solution. Each project can open a NuGet Package Manager window at the same time. This change applies to all type of projects that uses NuGet Package Manager.

ASP.NET tooling updates for both VS2015 Preview and VS2013 Update 4

All of the following tooling updates have been blogged with detail in "Announcing new Web Features in Visual Studio 2013 Update 4 RC", except two new features:

  • JSON editor IntelliSense for package.json/bower.json
  • JSON editor Duplicate property validation

     

JSON Editor Improvement

 

We have made some improvements in the JSON editor, including performance improvements such as loading JSON schema asynchronously, caching of the child schemas, and better IntelliSense. Additionally, there are the following new features:

  • JSON Schema validation - Add JSON schema validation feature, based on the schema that is defined in the schema drop-down list.
  • Un-minify context menu -You can right-click the JSON editor and select Un-minify context menu to un-minify any long arrays in the JSON file.
  • Reload Schemas context menu -Visual Studio will cache the schema that is downloaded from Internet and will use the cache even after you restart Visual Studio. If you know the schema is changed, you can use the context menu Reload Schemas Ctrl+Shift+J to re-download the current used schema in the active JSON document, and then use it immediately on the current document.
  • IntelliSense for package.json/bower.json - In addition to proving IntelliSense and validation for both package.json and bower.json files, Visual Studio also provides live IntelliSense for both Bower and NPM packages directly within the JSON editor

  • Duplicate property validation - The JSON editor will now provide validation for any duplicate properties. This helps catch this common problem with JSON file authoring.

HTML Editor

 

Microsoft improved the HTML editor with some bug fixes, updated IntelliSense for web standards, and introduced the following new features:

  • Better client template formatting - The HTML editor does not parse or format double-curly syntax {{…}} anymore. This is to make sure that the content of that syntax is not treated as being HTML and therefore being invalidated, nor does it try to format them, which cannot be done correctly by using the HTML formatter. This is great for Angular, Handlebars, Mustache, and other double-curly template syntaxes.
  • Support for custom elements, polymer-elements and attributes - The HTML Editor no longer validates unknown attributes for custom elements, as there will be many custom made tags in different frameworks. Therefore, there will no longer be squiggles under the unknown elements.
  • Basic IntelliSense for Web Components - HTML Editor has IntelliSense for <link rel="import" /> that is part of the Web Components standard.
  • HTML element tooltips - Tooltips are supplied for HTML elements in the editor.
  • #region support The HTML editor now supports region folding. You can use surrounding snippets to surround the current selection as well.
  • Todo/Hack comment support in Task List – The HTML editor now supports Todo, Hack etc. comment token and display them in Task List.
  • Angular icons - Both Angular directives (ex. <ng-view>) and attributes (ex. ng-controller) now show in IntelliSense with an Angular logo to make it easy to identify them.
  • Bootstrap icons - The IntelliSense provided in HTML class attributes now shows the Bootstrap logo if the class name was defined by the Bootstrap CSS file.

CSS/LESS/Sass Editor

  • Todo/Hack comment support in Task List– The CSS/LESS/Sass editor now supports Todo, Hack etc. comment token and display them in Task List.
  • @viewport fix for LESS editor - In LESS editor, @viewport will not show verification warning anymore.
  • Provide many more snippets – The CSS/LESS/Sass Editor now provides more snippets to ease the development experience.

Browser Link

  • CSS automatically synchronous - Now, saving the CSS file or changing it externally (such as by using a LESS/SASS compiler) will cause the whole CSS file to reload in the browser. If the file is in a state where it cannot auto-sync, Ctrl + S will cause an automatic reload, and this should put it back into a good state without having to refresh the linked browsers (Ctrl + Alt + Enter). The feature can be disabled in the toolbar.

WebJobs Tooling

Visual Studio now supports controlling web jobs through Server Explorer WebJobs' node inside an Azure Website in the following ways:

  • View WebJobs nodes underneath Website nodes in Server Explorer.
  • Start/Stop Continuous WebJobs from Server Explorer.
  • Run On-demand or Scheduled jobs from Server Explorer.
  • View WebJob Dashboard from Server Explorer.

You can use the View Dashboard context menu to go to the Azure website's WebJob dash board.

WebJobs SDK

  • WebJobs SDK is pre-installed in the Azure WebJob project templates.

ASP.NET runtime updates

The following runtime packages are added to both VS2013 Update 4 and VS2015 Preview, except EF6.1.2-beta1 and EF 7, which are in VS2015 Preview only.

Microsoft ASP.NET and Web ASP.NET MVC 5.2.2

Template packages are updated to use ASP.NET MVC 5.2.2. This release does not have any new features or bug fixes in MVC. We made a change in Web Pages for a significant performance improvement, and have subsequently updated all other dependent packages we own to depend on this new version of Web Pages.

ASP.NET Web API 5.2.2

In this release we have made a dependency change for Json.Net 6.0.4. For more information on what is new in this release of Json.NET, see Json.NET 6.0 Release 4 - JSON Merge, Dependency Injection. This release does not have any other new features or bug fixes in Web API. We have subsequently updated all other dependent packages we own to depend on this new version of Web API.

ASP.NET Web API OData 5.3.1

See this release note for Web API OData 5.3. See this release note for Web API OData 5.3.

SignalR 2.1.2

Template packages are updated to use SignalR 2.1.2. For more information, see the SignalR 2.1.2 release note on GitHub.

Microsoft Owin 3.0 Package

Template packages are updated to use Microsoft Owin 3.0 NuGet packages. For more information, see this Katana 3.0 release note.

NuGet 2.8.3

Support for DevExtreme project and BizTalkProject are added to 2.8.3. For more information, see the NuGet 2.8.3 Release Notes.

ASP.NET Identity 2.1.0

Added SignInManager to make it easier to use security features such as Account Lockout, and Two-Factor Authentication for login. For more information, see Announcing RTM of ASP.NET Identity 2.1.0.

Entity Framework 6.x

This release includes the EF6.1.2-beta1 version of the runtime and tooling. EF6.1.2 is mostly about bug fixes, you can see a list of the fixes included in EF6.1.2 on our CodePlex site.

The Entity Framework 6.1.1 runtime is included in a number of places in this release.

  • The runtime will be installed if you create a new model using the Entity Framework Tools in a project that does not already have the EF runtime installed.
  • The runtime is pre-installed in new ASP.NET projects, depending on the project template you select.

Note, VS2013 Update 4 only includes EF6.1.1 .

Entity Framework 7 Beta1 for VS2015 Preview Only

EF7 is a lightweight and extensible version of Entity Framework that enables new platforms and new data stores. Starting with EF7, Windows Phone, Windows Store, ASP.NET 5, and traditional desktop application can all now take advantage of Entity Framework. In addition to relational databases, EF7 also supports non-relational data stores such as Azure Table Storage and Redis. For more information on EF7, see our What is EF7 all about page.

WebForm 4.6 Improvements for VS2015 Preview Only

ASP.NET team continues to improve ASP.NET Web Forms. We added the following features in this release:

  • HTTP 2 support
  • Async Model Binding
  • Use Roslyn Code Dom Compilers

ASP.NET 5 Preview Tutorials

You can find ASP.NET tutorials in http://asp.net/vNext.

Here are the links that you can find from the "ASP.NET 5 Starter web" template as well:

Customize app

Run & Deploy

Get help

Known Issues

  • When publishing an ASP.NET 5 project and using the Precompile option, the content will be skipped if it had been previously published with the same version. The workaround is to change the version property in project.json.
  • ASP.NET 5 web projects need a wwwroot element in project.json. For existing projects you can add "wwwroot":".\". See https://github.com/aspnet/Home/wiki/Project.json-file for more information. If the wwwroot element is missing and web publish is invoked, an error is returned stating that kpm pack has existed with code 1.
  • When publishing an ASP.NET 5 project, the build is not verified before publish starts. The workaround here is to build your project before publishing.
  • After scaffolding an empty ASP.NET 5 project from the command line, the readme that is shown has old content. The contents should not be used directly in your projects.
  • For ASP.NET 5 projects, the IntelliSense project dropdown doesn't associate code files in subfolders with the project. Instead Miscellaneous Files is shown.
  • For ASP.NET 5 projects, in a project targeting both aspnet50 and aspnetcore50 installing a package targeting desktop using NuGet Package Manager for solution fails with a 404. The work around is to install the package at the project level instead.
  • For ASP.NET 5 projects, in a project targeting both aspnet50 and aspnetcore50 installing a package using NuGet Package Manager doesn't install it in the correct dependency section. For e.g. a package that is only supported on aspnet50 will still be dropped under the shared dependency section in the project.json. You will need to move it to the correct dependencies section.
  • Microsoft .NET Framework 4.6 (it can also be referred to as Microsoft .NET Framework 4.5.3) is installed after installing VS2015 Preview. Customers may also obtain this new version of .NET Framework 4.6 via stand-alone installer here or from the Windows 10 Tech Preview. VS2013, VS2012 and VS2010sp1 users may experience a warning dialog box popping up when either creating new Web Site or Windows Azure project or when opening existing projects. The warning dialog claims that "Configuring Web http://localhost:xxxxx/ for ASP.NET 4.5 failed". You can ignore this dialog box. For detailed workaround and patches, please see this post.

Summary

We'd love to hear your feedback. For Visual Studio tooling related issues, please submit bugs through Connect, send suggestions on UserVoice, and quick thoughts via Send-a-Smile in the Visual Studio IDE. For ASP.NET vNext, please provide feedback in GitHub or the ASP.NET vNext forum. If you ask a question in Stack Overflow, use the asp.net-vnext tag.  Thanks for being with us in this exciting time!

Katana, ASP.NET 5, and bridging the gap

$
0
0

This post is for developers that have been using the Microsoft Owin components (e.g. the Katana project) and want to know how it relates to ASP.NET 5.

As discussed in Katana’s roadmap, the next major version of Katana is being fully integrated into ASP.NET 5. This integration has resulted in several changes that make Katana v3.0 based components not directly compatible with 5. Developers and consumers of v3.0 based components may choose to fully migrate their components or use OWIN to help bridge the gap.

Migrate

Developers may choose to update their components to integrate directly with ASP.NET 5. ASP.NET 5 builds on the concepts, designs, and components initially developed in Katana so the migration process should be largely mechanical.Here is a list of changes made to Katana components that developers can use as a guide when migrating their own components. I will use the StaticFile middleware as a reference to demonstrate most of the changes.

Hosting and Repositories

The first thing you’ll notice looking at the roadmap is that we are building the new components on GitHub. The new code base is divided into many smaller repositories, with the roadmap showing where each component moved to.

Packages and Versions

The next most obvious change is renaming the packages and namespaces from Microsoft.Owin.* to Microsoft.AspNet.* to conform to the rest of ASP.NET. Due to the rename the package versions have been reset to v1.0.0.

Startup

The Startup class conventions have been refined. Katana would search for an assembly that specified the OwinStartup attribute and then fallback to searching all assemblies for a class named Startup or AssemblyName.Startup. ASP.NET does not define an attribute and it only searches the primary application assembly for a type named Startup (in any namespace). The Configuration(IAppBuilder app) method is now Configure(IApplicationBuilder app). Middleware can still define extension methods to add themselves to the pipeline.

Dependency Injection

The availability and usage of dependency injection has been significantly expanded. The Startup class constructor and its Configure method can both have parameters injected. IApplicationBuilder.ApplicationServices is the IServiceProvider available for any manual dependency resolution. Middleware can also take constructor parameters via injection, as well as having services injected per-request as parameters to the Invoke method. Middleware and applications can also access services from HttpContext.ApplicationServices or RequestServices.

Request Object Model

Implementing middleware should look familiar with a nextparameter and an Invoke method. The IOwinContext family of APIs have been renamed to HttpContext but don’t worry, it’s not the old System.Web HttpContext; moving middleware over should only need to account for minor refactoring. Under the hood things are a little different though. IOwinContext’s default implementation was based on the raw OWIN abstraction. HttpContext’s default implementation is based on an IFeatureCollection that exposes groups of functionality via feature interfaces. These feature interfaces can be implemented on top of differentservers (or on top of the OWIN abstraction), making the object model server independent. See this Channel 9 video for more details.

Platform

With ASP.NET 5 comes support for a new platform, the “cloud-optimized CLR”. Most of the ASP.NET 5 components have been cross-compiled to target both the full .NET CLR and the new platform. Katana v3.0 based components only target the full .NET CLR and will not run on the new platform.

Almost all of the Katana components have already been migrated to ASP.NET 5, there are just a few security middleware and the CORS middleware remaining. Note that migrated components will not be usable in a Katana v3 based application. Migration may also not be an option if you do not own the component.

OWIN Interop

Some developers will need their components to work with both Katana v3.0 based applications and ASP.NET 5. Developers and consumers may also not have the option to migrate their components and must attempt to use them as is. Katana v3.0 and ASP.NET 5 both support extensibility via OWIN and this can be used to enable interop between the two. OWIN is a community standard designed to reduce component interdependencies in an HTTP pipeline for improved interoperability. OWIN based components can plug into ASP.NET 5 using the new OWIN pipeline builder (the standard is still a work in progress) or IAppBuilder extensions.

OWIN Builder

ASP.NET 5 has built in support for the new OWIN pipeline builder model. See the extensions and samples. Middleware may use any OWIN helpers they wish internally, including the IOwinContext if that’s what they’re already using. Middleware that depend on IAppBuilder and/or the OwinMiddleware base class won’t be able to use the OWIN pipeline builder approach directly. Removing these dependencies is recommended.

IAppBuilder Bridge

Middleware that can’t remove their IAppBuilder or OwinMiddleware dependencies can use a modified approach to run in ASP.NET 5. See this linked sample for an IApplicationBuilder extension that provides an IAppBuilder for use with Katana v3 based middleware. This extension creates a new AppBuilder instance and then wraps the OWIN pipeline builder pattern around it to integrate into ASP.NET 5. The sample also shows how to populate IAppBuilder.Properties data that the middleware may depend on, the data protection provider in this case.

The Thinktecture folks helped write this sample and used it to get their Katana v3 based identity framework up and running on ASP.NET 5, including Katana security middleware and Web API v2. This is a nice quick way to get existing components up and running, but should be considered a temporary solution. The OWIN community is moving away from IAppBuilder in favor of the OWIN pipeline builder referenced above. The Katana v3.0 versions of migrated components will also only receive incremental bug fixes, not new feature development. As noted above, Katana components will only work on the full .NET framework, not on the new Core framework.

Note that the OWIN integration is limited to standard and common functionality defined by the community so not all ASP.NET 5 features will be available. For example parts the security middleware pattern will not be able to interoperate across between OWIN and ASP.NET 5 because OWIN does not define a standard for them.

This post was written by Chris Ross. He can be reached on Twitter @tratcher


Content negotiation in MVC 6 (or how can I just write JSON)

$
0
0

Intro

In this blog, I intend to provide a simplified how-things-work and how-to-change-the-behavior. It is not intended as a deep dive into content negotiation.

Since Web API 1 controller code can return an object of an arbitrary type and the framework will send it as JSON or XML to the client. The process of picking the output format is called “content negotiation”. The basic rules can be described simply as:

1. The framework will attempt to return the format that the client asked for using the Accept header.

2. In absence of a specific format requested or inferred, the default format is JSON.

3. If the format the client asked for is not available the framework will return the default format JSON. (Example: accept header was application/DoesNotExistFormat)

MVC 6 combined Web API and MVC into a single framework. Although content negotiation was revamped, the basic rules have not changed. There are some enhancements to the API, factoring of the code and a few behavior improvements for edge cases have been added.

A common question about content negotiation is: Why is my API returning XML by default. Nine out of ten times the reason is that the developer is using a browser to test the API, using Chrome or FireFox. The Chrome browser is asking for XML in the accept header and the server follows the above rules.

Here is a simple GET request from Chrome to localhost:

GET / HTTP/1.1
Host: localhost:5001
Proxy-Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,he;q=0.6

Note that the accept header asks for several formats including application/xml, but does not ask for application/json. Hence the server will just return the only format it can match which is XML.

In contrast if we made the same request with IE it will simply not ask for XML:

GET / HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US,en;q=0.7,he;q=0.3
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: localhost:5001
DNT: 1
Proxy-Connection: Keep-Alive

Since the browser did not ask for any format that the framework recognizes, it will fallback to the default rule and return JSON data.

Note: q factors are assigned to specific accept headers, this is something content negotiation will support. This blog doesn’t cover these scenarios.

What do I do about it

There are a few ways to look at it, the simplest one is to use the right tool for the right job. The browser’s job is to render HTML, so why use it to test your APIs? There are much better tools for that, like Fiddler, browser dev tools, or test your javascript call to the API rather than hitting it directly from the browser.

For me this is where I stop, the API is behaving as expected and will support any client following the HTTP spec.

Thanks for your advice, but I still want to just return JSON!

Many developers just care about returning JSON, while others still want to be able to content negotiate the result for some actions.

Here are some ways to implement the behavior.

Return a JSON result explicitly

  • Pros – The code is simple to read, and there is no magic involved. It’s easy to test, and you can mix in other action results.
  • Cons – The code is explicit, and there is no notion of what is going to get returned for any introspection APIs such as “ApiDescriptionProvider”. ApiDescriptionProvider is the replacement to ApiExplorer.
  1. publicIActionResult GetMeData()
  2. {
  3.     var data = GetDataFromSource();
  4.  
  5.     if (data == null)
  6.     {
  7.         return HttpNotFound();
  8.     }
  9.  
  10.     return Json(data);
  11. }

Remove the XML output formatter from the system.

  • Pros – A single change in options.
  • Cons – This is a global approach that removes XML from content negotiation. If one of the clients requires XML it is not longer available by default.

note: In MVC6 XmlOutputSerializer was broken into two distinct serializers. The one below is registered by default.

  1. services.Configure<MvcOptions>(options =>
  2.     options
  3.     .OutputFormatters
  4.     .RemoveAll(
  5.         formatter => formatter.Instance isXmlDataContractSerializerOutputFormatter)
  6. );

Use the [Produces(“application/json”)] attribute – New in MVC 6

  • Pros – Keeps code in the action simple, and can be applied locally or globally in various ways.
  • Cons – Can’t mix a string with Produces.

By applying the attribute to an action

  1. [Produces("application/json")]
  2. publicList<Data> GetMeData()
  3. {
  4.     return GetDataFromSource();
  5. }

By adding the filter globally to startup.cs

  1. services.Configure<MvcOptions>(options =>
  2.     options.Filters.Add(newProducesAttribute("application/json"))
  3. );

By applying it to a base class

  1. [Produces("application/json")]
  2. publicclassJsonController : Controller { }
  3. publicclassHomeController : JsonController
  4. {
  5.     publicList<Data> GetMeData()
  6.     {
  7.         return GetDataFromSource();
  8.     }
  9. }

What else changed in content negotiation in MVC 6

1. If the controller returns a string (regardless of declared return type), expect to get a text/plain content type.

  1. publicobject GetData()
  2. {
  3.     return"The Data";
  4. }
  5.  
  6. publicstring GetString()
  7. {
  8.     return"The Data";
  9. }

2. If the controller return null or the return type is void, expect a status code of 204 (NoContent) rather than 200. And the body will be empty.

  1. publicTask DoSomethingAsync()
  2. {
  3.     // Do something.
  4. }
  5.  
  6. publicvoid DoSomething()
  7. {
  8.     // Do something.
  9. }
  10.  
  11. publicstring GetString()
  12. {
  13.     returnnull;
  14. }
  15.  
  16. publicList<Data> GetData()
  17. {
  18.     returnnull;
  19. }

Both the behaviors above are controlled by the HttpNoContentOutputFormatter and the TextPlainFormatter. Both these behaviors can be overridden by removing the formatters from the Options.OutputFormatter collection, similarly to how the XML formatter was removed in the example above.

Yeoman generators for ASP.NET 5

$
0
0

Hi everyone, this post is in my name but it’s authored by Sourabh Shirhatti. He was a Program Manager Intern from the University of Texas at Austin that I’ve had the pleasure of working with this summer. This post is long overdue, we should have posted this a while back. Better late than never :)

 

yo-gif

Building complex modern web applications used to be difficult because of the lack of tooling to maintain and develop client-side code. Recent Open Source projects have made it easier to manage complex client-side code. Writing Coffeescript/Typescript has made Javascript more manageable. Likewise, SASS/LESS have alleviated many of the pain points of CSS.

However, this has resulted in a more involved build process to prepare an application for deployment. In addition to compiling your Coffeescript and SASS, readying an application for deployment involves bundling and minification of CSS, minification and possibly inlining of Javascript among other tasks.

Task runners like Grunt and Gulp can help perform most of the the mundane work for you after you've configured them, but configuring them is no trivial task. Take a look at a sample GruntFile

Additionally, package managers like npm and bower help manage dependencies for increasingly complex client-side code.

Setting up all these tasks for every new project can be a daunting task. That's where yeoman comes in handy.

Introducing Gulp, Grunt, Bower, and npm support for Visual Studio is a good read about task runner support in Visual Studio

What's yeoman?

Yeoman is a client-side stack of tools that help building web applications. The Yeoman workflow is comprised of three tools:

  1. a scafolding tool (yo)
  2. a task-runner/build tool (Grunt, Gulp); and
  3. a package manager (Bower, npm)

According to the yeoman homepage, "Yeoman helps you kickstart new projects, prescribing best practices and tools to help you stay productive".

 

What's yo?

As the Yeoman website succintly puts it, "yo scaffolds out a new application, writing your Grunt configuration and pulling in relevant Grunt tasks and Bower dependencies that you might need for your build."

 

Why do we care about yeoman?

Yeoman runs as a command-line interface written in Node.js providing cross-platform support for Mac, Windows and Linux. A Yeoman generator for ASP.NET 5 emphasizes our continued effort to enable cross-platform development of ASP.NET.

 

How do I get started with Yeoman?

Install Node.js

  1. Since yeoman runs on Node.js, you can get started by installing the binaries from the Node.js website or using a package manager (brew, apt-get, yum, etc).

    Note: You might want to install nodejs-legacy on Debian systems to prevent conflicts with Amateur Packet Radio node Program

OSX / Linux

In a terminal you can execute the following command.

if (if ! (which node > /dev/null); then echo "Node.js not found"; fi && if ! (which npm > /dev/null); then echo "npm not found"; fi) then echo "Looks like you have both Node.js and npm installed"; fi

 

Windows

In a PowerShell prompt you can execute the following command.

if(!(get-command node -ErrorAction SilentlyContinue)){'node not found' | Write-Error } if(!(get-command npm -ErrorAction SilentlyContinue)){'node not found' | Write-Error }

Install yo

  1. Let's use npm to install yo as well as the ASP.NET 5 generator using the following command

    npm install -g yo generator-aspnet

How do I scaffold a new ASP.NET 5 application?

To get started with the Yeoman generator for ASP.NET, launch a Terminal (or powershell) window and type the following command

$ yo aspnet

You should see a response similar to the following.

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |      Welcome to the      |
   `---------´   |    marvellous ASP.NET    |
    ( _´U`_ )    |        generator!        |
    /___A___\    '--------------------------'
     |  ~  |     
   __'.___.'__   
 ´   `  |° ´ Y ` 

? What type of application do you want to create? (Use arrow keys)
❯ Console Application 
  Web Application 
  MVC Application 
  Nancy ASP.NET Application 

You can use the arrow keys to select a template type. In this article I will be creating a MVC Application.

Next, you will be prompted to name your application

[?] What's the name of your ASP.NET application? (MvcApplication1)

I am going to use the default name MvcApplication1, but you are free to rename your application.

On proceeding, the generator will create an empty application the following layout

.
├── MvcApplication1
│   ├── Controllers
│   │   └── HomeController.cs
│   ├── Models
│   │   └── User.cs
│   ├── Startup.cs
│   ├── Views
│   │   ├── Home
│   │   │   └── Index.cshtml
│   │   └── Shared
│   │       └── _Layout.cshtml
│   └── project.json
└── NuGet.config

6 directories, 7 files
Note you may want to install ASP.NET 5 runtime to get the command line tools.

 

How do I contribute to this project?

This project is hosted on GitHub at omnisharp/generator-aspnet and we accept pull requests from the community.

Sourabh Shirhatti

Adding New Items to Your ASP.NET 5 Project with Yeoman Subgenerators

$
0
0

Hi Sayed here, this post is graciously authored by Shayne Boyer who is a member of the ASP.NET community that I've been working with lately. Enjoy.

Sourabh Shirhatti did a great write up on the use of yeoman and the ASP.NET generator for creating projects, http://blogs.msdn.com/b/webdev/archive/2014/12/17/yeoman-generators-for-asp-net-vnext.aspx , but another advantage of yeoman is subgenerators for adding additional items to our project.

Creating a new Project

To summarize, creating a quick “HelloWorldMvc” application is easy with the aspnet generator.

$ yo aspnet

You will get the response of what type of project you want to create. Notice that there is a new “Class Library” project type now as well.

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |      Welcome to the      |
   `---------´   |   marvellous ASP.NET 5   |
    ( _´U`_ )    |        generator!        |
    /___A___\    '--------------------------'
     |  ~  |     
   __'.___.'__   
 ´   `  |° ´ Y ` 

? What type of application do you want to create? (Use arrow keys)
❯ Console Application 
  Web Application 
  MVC Application 
  Nancy ASP.NET Application 
  Class Library

Select the MVC Application, and the generator asks for the name of the application. Enter “HelloWorldMvc”; press enter and the scaffolding will commence and the project template is created.

spboyer-mac-dev:HelloWorldMvc shayneboyer$ tree
.
├── Controllers
│   └── HomeController.cs
├── Models
│   └── User.cs
├── Startup.cs
├── Views
│   ├── Home
│   │   └── Index.cshtml
│   └── Shared
│       └── _Layout.cshtml
├── project.json
└── wwwroot

Adding New Items to Your Project

If you have been Visual Studio user, you are familiar with the Add > New Item dialog

Screen Shot 2014-12-06 at 10.21.39 AM

when needing to add Controllers, Views, Class, etc. type files to your project. However, when developing in other IDEs such as Sublime Text or Brackets obviously this is not an option.

yo aspnet –help

Using this command, you can see all of the subgenerators that are available.

$ yo aspnet --help

Usage:
  yo aspnet:app [options] 

Options:
  -h,   --help  # Print generator's options and usage  Default: false

  --skip-install # Skip triggering kpm restore automatically  Default: false

Description:
    Creates a basic ASP.NET 5 application

Subgenerators: 

    yo aspnet:BowerJson [options] 
    yo aspnet:Class [options] <name>
    yo aspnet:CoffeeScript [options] <name>
    yo aspnet:Gruntfile [options] <name>
    yo aspnet:HTMLPage [options] <name>
    yo aspnet:JScript [options] <name>
    yo aspnet:JSON [options] <name>
    yo aspnet:MvcController [options] <name>
    yo aspnet:MvcView [options] <name>
    yo aspnet:PackageJson [options] 
    yo aspnet:StartupClass [options] 
    yo aspnet:TextFile [options] <name>
     yo aspnet:WebApiController [options] <name>

Adding any of the items is simple, move to the directory you want to have the new item placed in and execute the generator.

$ cd Controllers
$ yo aspnet:MvcController ContactController
You called the aspnet subgenerator with the arg ContactController
ContactController.cs created.
   create ContactController.cs

Now looking at the overall project tree I have added the new Controller and View.

├── Controllers
│   ├── ContactController.cs
│   └── HomeController.cs
├── Models
│   └── User.cs
├── Startup.cs
├── Views
│   ├── Contact
│   │   └── Index.cshtml
│   ├── Home
│   │   └── Index.cshtml
│   └── Shared
│       └── _Layout.cshtml
├── project.json
└── wwwroot

Yo Whats next?

Get involved, project is hosted on GitHub at omnisharp/generator-aspnet. I enjoyed adding the subgenerators and see opportunities for growth already. What would you like to see?

Shayne Boyer
@spboyer on twitter
http://www.tattoocoder.com

ASP.NET MVC 5.2.3, Web Pages 3.2.3 and Web API 5.2.3 Beta releases

$
0
0

While the MVC team is working hard on MVC 6 as part of the ASP.NET 5 effort, we also keep working on the 5.x packages. Today we are releasing a Beta of ASP.NET MVC 5.2.3, Web Pages 5.2.3 and Web API 5.2.3.

This preview release addresses 12 issues. Here is the full list.

Highlight of issues fixed

Web API Issues

2092 Significant performance improvement in the default overload for System.Net.HttpFormatting.ReadAsAsync by caching the default JSON formatter. This can result in improvements of 100s of milliseconds on the second call to ReadAsAsync (or similarly to the write method).

2103 Batch's inner request's Url not being decoded in WebHost scenarios.

2101 Error parsing MIME multipart when using irregular mime types

MVC Issues

2155 Remote attribute does not work boolean fields and Html.CheckBoxFor

2081 Performance improvement in OutputCacheAttribute for child action

2136 Attribute routing does not set ControllerContext.IsChild correctly

2172, 2048– Unobtrusive validation fixes

MVC and Web Pages Issues

2085 Performance improvement in rendering Razor views

2119 Performance improvement in rendering attributes in Razor

Shout Out

We want to convey a big thank you to Nick Craver and Marc Gravell, who reported two of the performance issues we resolved in this release and provided a pretty cool Pull Request to fix one of them.

Issue 2085 in detail

Issue 2085 was about the fact the MVC copied ViewData for partial views, and templated helpers. In a reasonably large page with a reasonable amount of data in the ViewBag this proves out to be rather costly. We are now using a copy on write strategy instead. We took this improvement over to MVC 6 as well.

The Test

We built a test site, that put about 50 items in the ViewBag. For each of these items we rendered a partial view. This is similar to having 50 templated helpers (such as DisplayFor and EditorFor) used on a page.

We ran two types of tests:

1. Load the site with a constant stream of requests at the rate of 100 requests/second, and compare memory utilization and garbage collection characteristics for MVC 5.2.2 and MVC 5.2.3.

2. Load the site with maximum amount of requests and compare the requests/second rate between MVC 5.2.2 and MVC 5.2.3.

Results
Test 1

The interesting data in this scenario as the reduction of time spent in GC and reduction in overall allocations. Note that Gen2 garbage collection count went down from 57 to 1! And the time in GC was sliced almost three fold.

Area

5.2.2

5.2.3

Delta %

Total request (count)

2,911

2,869

 

Trace duration (seconds)

30

30

 

Request/second

97.03

95.63

 

GC CPU Samples (msec)

12,139.00

6,682.00

45%

Total allocations (MB)

    18,049.79

12,602.08

30%

Total GC Pause (msec)

1,103.20

663.00

40%

Gen0 GC (count)

76

107

-41%

Gen1 GC (count)

317

106

67%

Gen2 GC (count)

57

1

98%

CPU / request (msec/req)

4.17

2.33

44%

% CPU Time spent on GC

6.40%

2.30%

64%

Test 2

In this scenario the number of requests/sec went up 70%, and less time was spent in GC.

Area

5.2.2

5.2.3

Delta %

Total request (count)

5,246

8,895

 

Trace duration (seconds)

30

30

 

Request/second

174.87

296.50

70%

GC CPU Samples (msec)

39,615

34,704

12.40%

Allocations/Request (MB/Request)

6.382

4.739 

34.66%

Total GC Pause (msec)

2,974.60

3,215.70

-8.11%

Gen0 GC (count)

76

99

-30.26%

Gen1 GC (count)

317

368

-16.09%

Gen2 GC (count)

57

45

21.05%

CPU / request (msec/req)

87.42

155.63

-78.03%

% CPU time spent on GC

8.60%

7.80%

9.30%

We hope you enjoy these performance and functionality improvements!

Running ASP.NET 5 applications in Linux Containers with Docker

$
0
0

As a part of our ASP.NET 5 cross-platform efforts, we are actively working on making applications written in ASP.NET 5 easy to deploy and ship on Linux and Mac OS X. A while ago, we have released the first official Docker image by Microsoft: the ASP.NET 5 Preview Docker Image.

Docker is an open source project that makes it easier to run applications in sandboxed application containers on Linux. With the ASP.NET 5 Docker image, you can get a base image where the ASP.NET 5 bits are already installed to run on Linux for you. All you need to do is add your application to the image and ship it so it will run in an app container!

 

In this tutorial we will show how a simple application written in ASP.NET 5 Preview can be deployed to a Linux Virtual Machine running on Microsoft Azure cloud using Docker. The tutorial can be executed on a Linux or Mac OS X machine where Docker client is installed (or you can ssh into the Linux VM you will use). Once Windows client for Docker is available, you will be able to run these commands on Windows and once Windows Server container support comes out you will be able to use Docker to manage Windows Server containers.

NOTE: Both ASP.NET 5 (vNext) and the Docker image are in preview and the following instructions are subject to change in the future. Please refer to Docker Hub page and GitHub repository for latest documentation on how to use the Docker image for ASP.NET 5.

Step 1: Create a Linux VM with Docker

As Docker only runs on Linux today, you will need a Linux machine or VM to run Docker on your server. You can find Docker installation instructions here or follow the Getting Started with Docker on Azure to get a Docker-ready Linux VM on Azure.

In this tutorial we will assume you have a Linux Virtual Machine on Azure with Docker installed. If you are using some other machine, most of this tutorial will still be relevant.

Step 2: Create a container image for your app

In order to deliver your ASP.NET application to the cloud, you will need to create a container image containing your application.

Docker container images are layers on top of each other. This means your application is an addition on top of a “base image” –in this case the base image will be microsoft/aspnet. The image layers are stored as diffs, therefore while deploying your application, your image will not contain the Linux distribution or the ASP.NET binaries; it will only contain your application, making it small in size and quickly deployable.

Creating a Docker image is done using a file called Dockerfile. Similar to a Makefile, the Dockerfile contains instructions telling Docker how to build the image.

For the sake of this tutorial, we will use the sample HelloWeb application from aspnet/Home repository on GitHub. First, clone this repository on your development machine and go to the HelloWeb directory using git:

git clone git@github.com:aspnet/Home.git aspnet-Home
cd aspnet-Home/samples/HelloWeb

In this directory you will see the following files:

├── Startup.cs
├── image.jpg
└── project.json

We are going to create a file called Dockerfile in this directory with the following contents:

FROM microsoft/aspnet

COPY . /app
WORKDIR /app
RUN ["kpm", "restore"]

EXPOSE 5004
ENTRYPOINT ["k", "kestrel"]

Let's go through this Dockerfile line by line. The first FROM line tells Docker that we will use the official ASP.NET image on Docker Hub as our base image.

The COPY line tells Docker that we will copy contents of this folder (.) to the /app directory of the container and the WORKDIR instruction will move to the /app directory.

The RUN instruction tells Docker to run the kpm restore command to install the dependencies of the application. We do this before running out application for the first time.

The EXPOSE instruction will inform Docker that this image has a service which will be listening at port 5004 (see project.json of the sample file for details). Lastly, the ENTRYPOINT instruction is the command executed to start the container and keep it up and running. In this case it is the k kestrelcommand, starting the Kestrel development server for ASP.NET 5. Once executed, this process will start listening to HTTP connections coming from port 5004. 

Step 3: Build the container image

Once we have Dockerfile ready, the directory should look like this, a Dockerfile residing with next to the application:

├── Dockerfile
├── Startup.cs
├── image.jpg
└── project.json

Now we will actually build the Docker image. It is very simple –just run the following Docker command in this directory:

docker build -t myapp .

This will build an image using the Dockerfile we just created and call it myapp. Every time you change your application, a new image can be built using this command. After this command finishes, we should be able to see our application in the list of Docker images on our Linux VM by running the following command on our development machine:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
myapp               latest              ccb7994d2bc1        39 seconds ago      499.8 MB
microsoft/aspnet    latest              16b1838c0b34        12 days ago         473.4 MB

As you can see, your app and the ASP.NET image are listed as images that exist on your machine.

Now we are ready to deploy our application to the cloud.

Step 4: Run the container

Running the container is the easiest part of the tutorial. Run the following Docker command on your development machine:

docker run -t -d -p 80:5004 myapp
  • The -t switch attaches a pseudo-tty to the container (this switch will not be necessary in future versions of ASP.NET 5).
  • The -d switch runs the container in the background, otherwise the web server's standard input/output streams would be attached to our development machine's shell.
  • The -p switch maps port 80 of the VM to port 5004 of the container. In this case, connections coming to port 80 of the VM will be forwarded to our container listening on port 5004.
  • Lastly, myapp is the Docker image name we are using to start the container. We built this image in the previous step.

Once the container is started, the following command can be used to show containers running on your machine:

$ docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED              STATUS              PORTS                  NAMES
f70bd9ffbc36        myapp:latest        "/bin/sh -c 'k kestr   About a minute ago   Up About a minute   0.0.0.0:80->5004/tcp   mad_goodall

Our container has started! However, we are not quite done yet. We need to complete the endpoint port mapping for Azure VM. You need to go to the Azure Management Portal to map public TCP port 80 to internal port 80 on your Linux VM (see relevant tutorial here).

Now let's head to the browser to see if it is working. Open http://your-cloud-service-name.cloudapp.net:80/ in your web browser:

Voila, you have an ASP.NET 5 application running on Linux inside a Docker container!

If your application is slightly different than the single-project sample application we used, you can learn more about writing Dockerfiles here and build your own images with custom commands.

Conclusion

We will continue to invest in running ASP.NET 5 applications on Linux and Docker and we are happy to bring you the Microsoft's first official Docker image: ASP.NET 5 Preview Image.

Since this tutorial depends on previews of ASP.NET 5 and its Docker image, the exact usage instructions may change over time. Please head over to Docker Hub page or GitHub repository to see up-to-date instructions.

Please send us your feedback and help us improve this Docker image by opening new issues on GitHub repository.

Ahmet Alp Balkan (@ahmetalpbalkan)
Software Engineer, Microsoft Azure

Viewing all 7144 articles
Browse latest View live


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