I am developing a web service using ASP.NET WEB API 2 and Owin and it is supposed to run as a windows service.
Simple caching using CacheOutputUntilToday(23,55) works fine but I want to add the authorization header to the cache key, since it seems it is not included in the key.
For this reason I created a class that implements ICacheKeyGenerator:
using System.Web.Http.Controllers;
using System.Net.Http.Headers;
using WebApi.OutputCache.V2;
class CustomCacheKeyGenerator : ICacheKeyGenerator
{
public string MakeCacheKey(HttpActionContext context, MediaTypeHeaderValue mediaType, bool excludeQueryString = false)
{
return context.Request.Headers.Authorization.ToString() + context.Request.RequestUri.ToString();
}
}
and I use it in the Startup.cs as shown:
HttpConfiguration config = new HttpConfiguration();
config.CacheOutputConfiguration().RegisterDefaultCacheKeyGeneratorProvider(() => new
CustomCacheKeyGenerator());
The command installutil myservice.exe gives back the following error:
Installing assembly 'C:\Users\ISOI\Desktop\SalesRepMobileAppService\SalesRepMobi
leAppService\bin\Release\SalesRepMobileAppService.exe'.
Affected parameters are:
logtoconsole =
logfile = C:\Users\ISOI\Desktop\SalesRepMobileAppService\SalesRepMobileAppSer
vice\bin\Release\SalesRepMobileAppService.InstallLog
assemblypath = C:\Users\ISOI\Desktop\SalesRepMobileAppService\SalesRepMobileA
ppService\bin\Release\SalesRepMobileAppService.exe
An exception occurred while trying to find the installers in the C:\Users\ISOI\D
esktop\SalesRepMobileAppService\SalesRepMobileAppService\bin\Release\SalesRepMob
ileAppService.exe assembly.
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the
requested types. Retrieve the LoaderExceptions property for more information.
Aborting installation for C:\Users\ISOI\Desktop\SalesRepMobileAppService\SalesRe
pMobileAppService\bin\Release\SalesRepMobileAppService.exe.
An exception occurred during the Install phase.
System.InvalidOperationException: Unable to get installer types in the C:\Users\
ISOI\Desktop\SalesRepMobileAppService\SalesRepMobileAppService\bin\Release\Sales
RepMobileAppService.exe assembly.
The inner exception System.Reflection.ReflectionTypeLoadException was thrown wit
h the following error message: Unable to load one or more of the requested types
. Retrieve the LoaderExceptions property for more information..
The Rollback phase of the installation is beginning.
See the contents of the log file for the C:\Users\ISOI\Desktop\SalesRepMobileApp
Service\SalesRepMobileAppService\bin\Release\SalesRepMobileAppService.exe assemb
ly's progress.
There are so many different solutions for this out there but none worked for me until now.
Any help would be highly appreciated
I am developing a web service using ASP.NET WEB API 2 and Owin and it is supposed to run as a windows service. Simple caching using CacheOutputUntilToday(23,55) works fine but I want to add the authorization header to the cache key, since it seems it is not included in the key. For this reason I created a class that implements ICacheKeyGenerator:
and I use it in the Startup.cs as shown:
The command installutil myservice.exe gives back the following error:
There are so many different solutions for this out there but none worked for me until now. Any help would be highly appreciated