Monday, June 15, 2015

MVC6 SecretManager

I tried to install ASP.NET MVC6 Secret Manager package with DNVM  1.0.0-beta4. It failed with:
Unable to locate SecretManager >= 1.0.0-beta4-10173
There is an easy fix: you can remove the last part of the version identifier.

  1. Open project.json file
  2. Change version to 
 "dependencies": {
    "SecretManager": "1.0.0-beta4-*"
  },
Files to be changed:
Package path:%UserProfile%\.dnx\packages\SecretManager\1.0.0-beta4\app\project.json
Cache path:%UserProfile%\.dnx\bin\packages\SecretManager\1.0.0-beta4\app\project.json

Wednesday, June 10, 2015

RouteValueDictionary

I got an error recently when I enable DonutCache donutHole-based caching for a RenderAction:
Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
It seems RouteValueDictionary cannot manage IEnumerable or String[] as a parameter. The solution is simple, it's a well-known issue:
http://stackoverflow.com/questions/19960420/adding-array-of-complex-types-to-routevaluedictionary

So this is how you can use the extension method:
Html.RenderAction(
                             ActionName,
                             ControllerName,
                             new RouteValueDictionary(new 
                             {      usual properties here }));