HotTowel - unable to upgrade to webapi 2 (vs2013) - hottowel

I have upgraded to Visual Studio 2013, and naturally I wanted to upgrade HotTowel, Breeze and all the other friends to also support MVC5, WebApi2, EF6 etc.
After a lot of back and forth, I have managed to update to WebApi2 and Breeze for WebApi2 + EF6. But HotTowel struggles.
I am unable to get HotTowel back, because it kicks in the Package Manager Console with the message:
install-package : Already referencing a newer version of 'Microsoft.AspNet.WebApi'
What does that mean? On the nuget page it says that it depends on: Microsoft.AspNet.WebApi (≥ 4.0.30506.0). My version of webapi is 5.x.x which is over the required 4.0xx.
Can anyone help me get HotTowel back?
Thanks.

So it all depends on where you are now. I suggest removing the packages and dll's and starting fresh. Start with a clean project and install-package hottowel.angular. If you want to try to piecemeal it together, it can work but it may be more painful.
If you started with the older hottowel, asp.net web api 2 broke it. SO the newest one uses the latest features. If you want web api v2, use hottowel.angular.breeze.
The issue is not HotTowel, its the incompat with Web Api 2 and some other MSFT features.
For more details, see this link: http://www.johnpapa.net/hottowel-angular-and-asp-net-web-api-2-compat/

Related

Installing MVC on asp.net Core in visual Studio 2015

I created an empty ASP.NET 5 to work with .NET Core. I am trying to add MVC package to the application but I am receiving an Error that the Versions are not compatible, although I tried lots of MVC versions.
Anyone has an idea about the problem? thank you!
You need Nuget packages in the Microsoft.AspNetCore.Mvc namespace. You're currently trying to install Microsoft.AspNet.Mvc 5.2.3, which is the traditional MVC package and only works with full .NET.
If you're working with .NET Core you should be using Microsoft.AspNetCore.* packages. (Microsoft.AspNet.* packages target the full .NET framework.)
Your screenshot shows a dependency on DNX. You do realize that's a pre-release technology? I don't mean to be rude but I'm curious as to why you would be targeting the pre-release framework rather than RTM (which has been available for several months).
If you do want to work with the prerelease bits, you may need to tweak your NuGet feeds to be able to see the appropriate .NET Core packages (I definitely had to do this when working with .NET Core betas).

How to get ASP.NET MVC Music Store up and running with Visual Studio 2013/2015?

I want to get MVC Music Store tutorial application up and running with Visual Studio 2013/2015. Here are the steps that I've taken:
downloaded the latest version from Downloads page
unpacked it
opened it with Visual Studio 2013/2015 - got a migration report without errors but with some warnings
tried to build the solution, but it won't build - got a plenty of errors about missing type/namespace like that:
The type or namespace name could not be found (are you missing a using
directive or an assembly reference?)
How do I build and run locally the MVC Music Store project with Visual Studio 2013/2015?
There are two ways:
1) Download and install ASP.NET MVC 3 Tools from the official ASP.NET MVC 3 page or from Microsoft Download Center. It will install the required DLLS into the GAC.
2) Install the corresponding ASP.NET MVC 3 NuGet package into MvcMusicStore project using following command in the Package Manager Console:
Install-Package Microsoft.AspNet.Mvc -Version 3.0.50813.1
or
Install-Package Microsoft.AspNet.Mvc -Version 3.0.20105.1
After using either of the described ways you will be able to successfully build and run the MVC Music Store tutorial application.
Note that these ways are not conflicting with each other, so you may safely install ASP.NET MVC 3 Tools into your OS and install ASP.NET MVC 3 NuGet package into the project.
Install-Package Microsoft.AspNet.Mvc -Version 3.0.20105.1
Worked for me instead of Version 3.0.50813.1
I was running into the same problem as other mentioned here, tried installing the nuget package and was still getting an error.
My solution after following other advice here by installing the nuget package, the key to my solution was to make sure the project targeted "Microsoft Framework 4.0". I.E. Right mouse on the project node in the solution explorer, select properties, and within the "Application" page for the project select ".Net Framework 4.0".
All is working fine for me after this, seems VS was defaulting to 4.5.1.
HTH.
dan d:)

Add ASP.NET Web API Authentication in Visual Studio 2015 to existing project

In Visual Studio 2015, when selecting a Web API template, we can now select No authentication, Individual User Accounts, Organizational Accounts, or Windows Authentication. Visual Studio then generates large quantities of code and includes many nugget packages automatically.
If I already have an ASP.NET Web API project without authentication, is it possible to add all of the generated code and packages for one of these authentication options without having to rebuild the solution from scratch or manually add each package?
Thanks -
If you use the nuget package manager to search for identity you should be able to install it from there. There is an equivalent nuget command line incantation for nuget too:
Install-Package Microsoft.AspNet.Identity.Samples -Pre
Be careful though. The current version is prerelease and it may also install a number of dependent components Which may cause issues.
As with all such things, taking a full backup of the solution before starting the process is advisable!

Attempt by method 'HttpConfiguration..ctor(HttpRouteCollection)' to access method 'HttpConfiguration.DefaultFormatters()' failed

I have a Web API that has version 5.1.2 of the Microsoft.AspNet.WebApi.Client package installed.
I am trying to access the API from an ASP.NET MVC application, which also has the same version of the package installed.
However, in the Global.asax of the Web API project, on the line below, I get the following exception:
WebApiConfig.Register(GlobalConfiguration.Configuration);
Attempt by method 'System.Web.Http.HttpConfiguration..ctor(System.Web.Http.HttpRouteCollection)' to access method 'System.Web.Http.HttpConfiguration.DefaultFormatters()' failed.
I found that this error occurs when you have multiple projects pointing to different .net versions.
For example if you have a Web API project targeting .net 4.5 and a unit test project targeting .net 4.5.3 it seems that default settings mean nuget may silently update the .net 4.5 project references to incompatible versions one day when you open visual studio and cause your Web API project to fail with the recondite 'Attempt by method 'HttpConfiguration..ctor(HttpRouteCollection)' to access method 'HttpConfiguration.DefaultFormatters()' failed' error.
To avoid the error drop the higher .net version back on the new project to match the Web API project - for this example right click the unit test project, click properties, then change the target framework to .net framework 4.5.
In my case it was a discrepancy between versions of Microsoft.AspNet.WebApi.Client and Microsoft.AspNet.WebApi.Core, I tried updating both to the same version and it worked.
In my case, the issue was solved when I installed the Microsoft.AspNet.WebApi.Core as well. So three libraries should present and be in harmony (uninstall / install) Microsoft.AspNet.WebApi.Client, Microsoft.AspNet.WebApi.Core and Newtonsoft.json
same for the above answers in my case also it is working good after updating or reinstalling packages
Microsoft.AspNet.WebApi.Client
Microsoft.AspNet.WebApi.Core

How to obtain System.Web.Http.Tracing.dll?

I read about Web API having its own TraceWriter implementation with 2012.2, for example here, among other sources.
I am now using VS2013 with .NET 4.5.1 and the EnableSystemDiagnosticsTracing is nowhere to be found. It's meant to be defined in the HttpConfigurationTracingExtensions class which resides in the System.Web.Http.Tracing.dll. However, this assembly is nowhere to be found - not in list of assemblies in the Add Reference dialog, not in GAC.
Where is this assembly supposed to come from? Docs say it's part of .NET Framework 4, which I have installed. Also installed the ASP.NET Web API 2 Tracing 5.0.0 NuGet package. Is there some update? Should I re-install .NET Framework?
I know it's not a big deal to implement ITraceWriter myself but it bothers me not to know what happened with the built-in implementation.
Just install needed NuGet Package
Install-Package Microsoft.AspNet.WebApi.Tracing -Version 5.0.0
It's a little bit strange, but it is the right package
http://www.nuget.org/packages/microsoft.aspnet.webapi.tracing
If you installed the Tracing 5.0.0 NuGet package, it should be correctly included in your project. The moment it is installed, I believe a separate text file should open in VS showing the code you should include in your WebApiConfig.cs file.
I haven't created a Web API 2 project from scratch (only upgraded from pre-5.0 to 5.0 projects), but this is the code that should reside in your WebApiConfig.cs file:
// To disable tracing in your application, please comment out or remove the following line of code
// For more information, refer to: http://www.asp.net/web-api
config.EnableSystemDiagnosticsTracing();
And that should be it, if the package is installed correctly, tracing should now be used in your project.

Resources