ASP.NET and Web Tools 2012.2 RC
This document describes the release candidate of ASP.NET and Web Tools 2012.2. It was a pre-release update to Visual Studio Web Tooling and ASP.NET.
- Installation Notes
- Software Requirements
- New Features in ASP.NET and Web Tools 2012.2
- Known Issues and Breaking Changes
ASP.NET and Web Tools 2012.2 for Visual Studio 2012 can be installed from the ASP.NET and Web Tools 2012.2 home page (http://www.asp.net/vnext/overview/). This is an update to Visual Studio 2012, which is required.
This update does not support localized versions of Visual Studio 2012. This release is compatible with only English language Visual Studio. Localized support will be available in the RTM release.
Tutorials and other information about ASP.NET and Web Tools 2012.2 are available on the home page for the ASP.NET and Web Tools 2012.2 (http://www.asp.net/vnext/overview/fall-2012-update).
ASP.NET and Web Tools 2012.2 is a prerelease and not supported. If you have questions about working with this release you can post them to the ASP.NET forums (http://forums.asp.net/), where members of the ASP.NET community are frequently able to provide informal support.
The ASP.NET and Web Tools 2012.2 requires Visual Studio 2012 or Visual Studio Express 2012 for Web.
New Features in ASP.NET and Web Tools 2012.2
This section describes features that have been introduced in the ASP.NET and Web Tools 2012.2 release.
- Editor support for Knockout IntelliSense and pasting JSON as a class.
- Enhanced Website publishing (now Web Application Project and Website project have the same publish experience)
- Selective publish – for one or more files you can perform the following actions (after publishing to a Web Deploy endpoint):
- Publish selected files.
- See the difference between a local file and a remote file.
- Update the local file with the remote file or update the remote file with the local file.
ASP.NET MVC Templates
- Facebook – build a Facebook application using the new Facebook template. In just a few easy steps you can create a Facebook Canvas Application that gets data from the logged in user as well as integrates with friends. For more information on using the Facebook Application template see http://go.microsoft.com/fwlink/?LinkID=269921.
- FixedDisplayModes package – MVC project templates have been updated to include the new ‘FixedDisplayModes’ NuGet package, which contains a workaround for a bug in MVC 4. For more information on the fix contained in the package, refer to this blog post (http://blogs.msdn.com/b/rickandy/archive/2012/09/17/asp-net-mvc-4-mobile-caching-bug-fixed.aspx) from the MVC team.
- You can now create a VSIX that adds new templates to the ASP.NET MVC New Project dialog. Learn how here: http://go.microsoft.com/fwlink/?LinkId=275019
ASP.NET Web API
Web API has been enhanced with several new features:
- ASP.NET Web API OData
- ASP.NET Web API Tracing
- ASP.NET Web API Help Page
ASP.NET Web API OData
ASP.NET Web API OData gives you the flexibility you need to build OData endpoints with rich business logic over any data source. With ASP.NET Web API OData you control the amount of OData semantics that you want to expose. ASP.NET Web API OData is included with the ASP.NET MVC 4 project templates and is also available from NuGet (http://www.nuget.org/packages/microsoft.aspnet.webapi.odata).
ASP.NET Web API OData currently supports the following features:
- Enable OData query semantics by applying the [Queryable] attribute.
- Easily validat OData queries and restrict the set of supported query options, operators and functions
- Parameter bind to ODataQueryOptions directly to get an abstract syntax tree representation of the query that can then be validated and applied to an IQueryable or IEnumerable.
- Enable service-driven paging and next page link generation by specifying result limits on [Queryable] attribute.
- Control null propagation.
- Any/All operators in $filter.
- Infer an entity data model by convention or explicitly customize a model in a manner similar to Entity Framework Code-First.
- Expose entity sets by deriving from EntitySetController.
- Simple, customizable conventions exposing navigation properties, manipulating links and implementing OData actions.
- Simplified routing and controller selection using the ODataPathHandler.
- Expose service document and $metadata so you can generate clients (.NET, Windows Phone, Windows Store, etc.) for your Web API.
- Support for the OData Atom and JSON verbose formats. Limited support for the new OData JSON format in HTTP responses.
- Create, update, partially update (PATCH) and delete entities.
- Query and manipulate relationships between entities.
- Create relationship links that wire up to your routes.
- Complex types.
- Entity Type Inheritance.
- Collection properties.
- OData actions.
- Built upon the same foundation as WCF Data Services, namely ODataLib (http://www.nuget.org/packages/microsoft.data.odata).
For more information on ASP.NET Web API OData see http://go.microsoft.com/fwlink/?LinkId=271141.
ASP.NET Web API Tracing
ASP.NET Web API Tracing integrates tracing data from your web APIs with .NET Tracing. It is now enabled by default in the Web API project template. Tracing data for your web APIs is sent to the Output window and is made available through IntelliTrace. You can also install and enable ASP.NET Web API Tracing in any application using the ASP.NET Web API Tracing NuGet package (http://www.nuget.org/packages/microsoft.aspnet.webapi.tracing).
For more information on configuring and using ASP.NET Web API Tracing see http://go.microsoft.com/fwlink/?LinkID=269874.
ASP.NET Web API Help Page
The ASP.NET Web API Help Page is now included by default in the Web API project template. The ASP.NET Web API Help Page automatically generates documentation for web APIs including the HTTP endpoints, the supported HTTP methods, parameters and example request and response message payloads. Documentation is automatically pulled from comments in your code. You can also add the ASP.NET Web API Help Page to any application using the ASP.NET Web API Help Page NuGet package (http://www.nuget.org/packages/microsoft.aspnet.webapi.helppage).
For more information on setting up and customizing the ASP.NET Web API Help Page see http://go.microsoft.com/fwlink/?LinkId=271140.
Windows Azure Authentication
Windows Azure Authentication makes it simple to enable authentication for web applications hosted on Windows Azure using Windows Azure Active Directory. You can authenticate Office365 users, corporate accounts synced from on-premise Active Directory or users created in your own custom Windows Azure Active Directory domain.
For more information on enabling Windows Azure authentication see http://go.microsoft.com/fwlink/?LinkID=267940.
ASP.NET SignalR makes it simple to add real-time web capabilities to your ASP.NET application, using WebSockets if available and automatically falling back to other techniques when it isn’t.
For more information on using ASP.NET SignalR see http://go.microsoft.com/fwlink/?LinkId=271271.
ASP.NET Friendly URLs
ASP.NET FriendlyURLs makes it very easy for web forms developers to generate cleaner looking URLs(without the .aspx extension). It requires little to no configuration and can be used with existing ASP.NET v4.0 applications. The FriendlyURLs feature also makes it easier for developers to add mobile support to their applications, by supporting switching between desktop and mobile views.
For more information on installing and using ASP.NET Friendly URLs see http://www.hanselman.com/blog/IntroducingASPNETFriendlyUrlsCleanerURLsEasierRoutingAndMobileViewsForASPNETWebForms.aspx.
Known Issues and Breaking Changes
This section describes known issues and breaking changes that are in the ASP.NET and Web Tools 2012.2 release.
Repairing Visual Studio 2012 breaks ASP.NET and Web Tools 2012.2
If you install the ASP.NET and Web Tools 2012.2 and then repair the Visual Studio 2012 installation, the RTM versions of ASP.NET MVC 4 and ASP.NET Web Pages 2 will be restored. When you create an MVC 4 project you will see two entries for MVC 4 Web Applications in the New Project dialog in Visual Studio. To address this problem follow these steps:
- Close Visual Studio 2012
- Go to Add Remove Programs
- Uninstall Microsoft ASP.NET and Web Tools 2012.2
- Reinstall Microsoft ASP.NET and Web Tools 2012.2
Out of order installs of Visual Studio 2012
Installing an additional SKU of Visual Studio 2012 after installing the ASP.NET and Web Tools 2012.2 will require a repair operation. Consider the following sequence:
- Install Visual Studio 2012 Express for Web
- Install ASP.NET and Web Tools 2012.2
- Install Visual Studio 2012 Professional, Premium or Ultimate
Step 2 would only result in installing updates for Express for Web. To ensure that the additional SKU installed during step 3 contains the update you will need to repair the ASP.NET and Web Tools 2012.2 to install the updates for the last SKU installed. This also applies if the SKUs in Step 1 and 3 are reversed.
Creating Razor websites fails with non-English Visual Studio versions
Creating a new Razor website will fail on non-English versions of Visual Studio. Users who attempt to create such a website will receive a localized error message stating that the registry key “AspNetWebPages2VS11” could not be found. Users who encounter this error are advised that a localized version will become available at a later date.
The workaround is to switch to English. This can be accomplished by doing the following:
- Install the English language pack for Visual Studio 2012 from http://www.microsoft.com/en-us/download/details.aspx?id=30681.
- In the Visual Studio Options dialog (available under the Tools → Options menu), open Visual Studio’s international settings (which will be under the Environment tree node), select “English” from the language dropdown, and click OK to apply. Note that these terms will be translated in localized versions of Visual Studio.
- You will be prompted to close and restart Visual Studio. When Visual Studio resumes, the user interface will be in English. You will be able to create a Razor v2 website without error.
Installing Microsoft ASP.NET and Web Tools 2012.2 when Visual Studio is open
If VS is open during installation of Microsoft ASP.NET and Web Tools 2012.2, Visual Studio might end up in a bad state. It is recommended that users close all instances of Visual Studio before proceeding with install.
Canceling ASP.NET and Web Tools 2012.2 setup in the middle of installation
Canceling ASP.NET and Web Tools 2012.2 setup in the middle of installation will leave Visual Studio in a bad state. To address this problem follow these steps:
- Go to Add Remove Programs
- Uninstall Microsoft ASP.NET and Web Tools 2012.2, if present.
- Reinstall Microsoft ASP.NET and Web Tools 2012.2
NuGet error reported during project creation
After installing ASP.NET and Web Tools 2012.2 you may see the following error when creating an MVC 4 project
The ASP.NET and Web Tools 2012.2 ships NuGet 2.1 and will upgrade the extension in Visual Studio 2012. In some cases, the VSIX installer will fail to correctly update the VSIX. The following steps will allow you to address this problem:
- Start Visual Studio 2012 as an Administrator
- Go to Tools->Extensions and Updates and uninstall NuGet.
- Close Visual Studio
- Navigate to the ASP.NET and Web Tools 2012.2 installation folder:
- For Visual Studio 2012: Program Files\Microsoft ASP.NET\ASP.NET Web Stack\Visual Studio 2012
- For Visual Studio 2012 Express for Web: Program Files\Microsoft ASP.NET\ASP.NET Web Stack\Visual Studio Express 2012 for Web
- Double click on the NuGet.Tools.vsix to reinstall NuGet
Cannot add an Area to an MVC project when running a localized Visual Studio
After installing the ASP.NET and Web Tools 2012.2, users who are running a localized instance of Visual Studio 2012 will not be able to right click inside an MVC project and use the Add Area command. This problem will be addressed for RTM.
Adding a New Area in MVC projects creates a web.config file with invalid syntax.
The web.config file under the Areas\ \Views\ has incorrect versions in the assembly references. The tokens __WebPagesVersion__ and __MvcVersion__ are not replaced with a version number. It causes warning at build time and error at runtime when views in the area are rendered.
The workaround is after adding an MVC Area, open the web.config file in the area’s Views folder and replace __WebPagesVersion__ with 2.0 and __MvcVersion__ with 4.0.
Using SignalR item templates causes runtime error
If you are creating SignalR Hubs or SignalR PersistentConnections using the SignalR item templates you will get the following error at runtime:
Could not load file or assembly 'Microsoft.Owin.Host.SystemWeb, Version=0.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The workaround is to follow the steps below to reinstall the Microsoft.AspNet.SignalR.SystemWeb NuGet package:
- Open the Package Manager console: TOOLS -> Library Package Manager -> Package Manager Console
- Run the following command: update-package -reinstall -pre Microsoft.AspNet.SignalR.SystemWeb
This will force the package to be reinstalled from the public NuGet feed. NuGet will add the following binding redirect to your web.config which works around the problem:
<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.Owin.Host.SystemWeb" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-22.214.171.124" newVersion="126.96.36.199" /> </dependentAssembly> </assemblyBinding> </runtime>
Windows Azure Authentication Issues
Attempting to log in immediately after enabling Windows Azure Authentication results in the error “ACS50001: Relying party with name '0cfd4a9b-fa93-40e5-ad6e-9dc17e833110@711cc959-be31-4148-9b64-062ea678fa17' was not found. “
It may take up to five minutes for Windows Azure Authentication to be provisioned for your application. Please wait a few minutes and try again.
Role-based authorization fails when using Windows Azure Authentication
Windows Azure Authentication does not currently provide the necessary role claim so that role-based authorization can be performed. The role of the authenticated user must be manually retrieved from Windows Azure Active Directory.
Browsing to an application with Windows Azure Authentication results in the error “ACS20016 The domain of the logged in user (live.com) does not match any allowed domain of this STS”
If you are already logged in to a Microsoft Account (for example hotmail.com, live.com, outlook.com) and you attempt to access an application that has enabled Windows Azure Authentication you may get a 400 error response because the domain of your Microsoft Account is not recognized by Windows Azure Active Directory. To log into the application, log out from your Microsoft Account first.
Logging into an application with Windows Azure Authentication enabled and a X509CertificateValidationMode other than None results in certificate validation errors for the accounts.accesscontrol.windows.net certificate
Certificate validation is not required and should be left disabled. The thumbprint of the issuer certificate is validated by the WSFederationAuthenticationModule.
When attempting to enable Windows Azure Authentication the Web Authentication dialog shows the error “ACS20016: The domain of the logged in user (contoso.onmicrosoft.com) does not match any allowed domain of this STS.”
You may see this error when you have previously successfully logged in using a different Windows Azure Active Directory account from within the same Visual Studio process. Log out from the specified account or restart Visual Studio. If you previously logged in and selected the option to “Keep me signed in” then you may need to clear your browser cookies.
Web API Issues
Parsing issues in $filter and DateTime literals
The OData URI parser fails to parse partial datetime literals properly. For example, $filter=start eq datetime'2012-12-31T12:00' fails to parse properly. A workaround is to use the full literal, $filter=start eq datetime’2012-12-31T12:00:00’.
OData error response does not contain model state errors
When creating an error response using the CreateErrorResponse extension methods or HttpErrors directly the error is mapped to an OData error response. Any model state errors in the error response do not get propagated to the OData error response. To preserve the model state errors in the OData error response use the CreateODataErrorResponse extension method or ODataError directly and add descriptions of the model state errors to the OData error message.
OData JSON format only supports querying for feeds, entries, service document and errors.
There is no support for querying entity reference links, properties, and collections.
OData JSON format only supports querying a service.
There is no update support for OData JSON in this release.
OData JSON only supports full metadata and minimal metadata formats.
There is no support for no metadata and streaming scenarios.
MissingMethodException with message “Method not found: 'Int32 Microsoft.Data.OData.Query.SemanticAst.QueryNode.get_Kind()” when request specifies a $filter OData query option.
If you update to the latest version of the ODataLib NuGet package when using the OData query support in ASP.NET Web API you will get a MissingMethodException when handling requests that specify a $filter OData query option. The OData support in ASP.NET Web API requires version 5.2.0-rc1 or ODataLib as more recent versions contain an breaking API change.
You need to revert to using the 5.2.0-rc1 version of ODataLib to use ASP.NET Web API OData. In Visual Studio go to Build->Clean Solution to clean out the existing assemblies and then go to Tools -> Library Package Manager -> Package Manager Console. Run the following commands in the Package Manager Console:
Uninstall-Package Microsoft.Data.OData –RemoveDependencies –Force Install-Package Microsoft.Data.OData –Version 5.2.0-rc1 –Pre
Facebook Template Issues
Facebook Application template only works using .NET 4.5
You must select .NET 4.5 in the framework dropdown list in the New Project dialog to see the Facebook Application template in ASP.NET MVC 4.
Real-time Update Controller
The Facebook Application template allows user easily create a Web API Controller to handle real-time updates from Facebook. If your development machine is behind NAT, your Controller may not work without further network configuration. See here for details: http://facebook.stackoverflow.com/questions/5259467/can-a-computer-behind-a-nat-router-receive-realtime-updates-from-facebook
Query string values conflict with Facebook OAuth parameters
The following fields conflict with Facebook OAuth dialog's call back URL. Do not add your own query string values with the following names: code, error, error description, error reason.
Using Page Inspector with Facebook Template
You can't use the Page Inspector feature in Visual Studio 2012 while debugging your Facebook Application. The Page Inspector does not currently support iframes.
This article was originally created on November 28, 2012