asp.net-mvc - 无法在 MVC 应用程序中配置 Redis 缓存

标签 asp.net-mvc caching azure redis

我是 Azure Redis 缓存的新手。我刚刚在 Azure 门户中配置了 Redis 缓存。我已经通过 nuget 在我的项目中安装了 StackExchange.Redis。下面是连接Redis的代码

ConnectionMultiplexer connection = ConnectionMultiplexer.Connect("server.redis.cache.windows.net,ssl=true,password=primary access key");

        IDatabase cache = connection.GetDatabase();

连接时出现以下错误:

JIT Compiler encountered an internal limitation.

at StackExchange.Redis.ConfigurationOptions.OptionKeys.TryNormalize(String value)
at StackExchange.Redis.ConfigurationOptions.DoParse(String configuration, Boolean ignoreUnknown) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConfigurationOptions.cs:line 501
at StackExchange.Redis.ConfigurationOptions.Parse(String configuration) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConfigurationOptions.cs:line 279
at StackExchange.Redis.ConnectionMultiplexer.CreateMultiplexer(Object configuration) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 728
at StackExchange.Redis.ConnectionMultiplexer.<>c__DisplayClass24.<Connect>b__23() in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 745
at StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(Func`1 multiplexerFactory, TextWriter log) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 761
at StackExchange.Redis.ConnectionMultiplexer.Connect(String configuration, TextWriter log) in c:\TeamCity\buildAgent\work\3ae0647004edff78\StackExchange.Redis\StackExchange\Redis\ConnectionMultiplexer.cs:line 745
at App.Web.Controllers.HomeController.Index() in g:\Users\Workspaces\AlphaProject\App.Web\Controllers\HomeController.cs:line 42
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.ActionInvocation.InvokeSynchronousActionMethod()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()

请建议我一些连接 Redis 服务器的解决方案。

提前致谢。

最佳答案

您能否尝试使用控制台应用程序连接到 Redis 缓存来隔离问题,看看是否有效? 您也可以引用此示例在MVC中使用Redis缓存http://azure.microsoft.com/blog/2014/06/05/mvc-movie-app-with-azure-redis-cache-in-15-minutes/

关于asp.net-mvc - 无法在 MVC 应用程序中配置 Redis 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29506331/

相关文章:

javascript - 如何在asp.net MVC中使用href从javascript在新窗口中打开打开的窗口

c# - IDistributedCache 通过注入(inject)调用构造函数

.net - EntLib 缓存应用程序 block 的替代方案?

python - 如何将 Microsoft Azure 中的 pip 从 1.5.6 升级到 9.0.1?

Azure DNS/附加 CNAME 记录

c# - 使用 TextBoxFor 截断字符串

c# - TextArea 字段中的第一个新行被 Razor 忽略

google-chrome - Chrome 不缓存 <object> 请求

javascript - ReactJS-浏览器验证错误: no_account_error: No account object provided to acquireTokenSilent and no active account has been set

c# - 无法隐式列出到 IEnumerable