0
我有一个CMS编写的ASP.NET MVC。我编写了一个自定义路由处理程序,用于查看传入路径并确定路由的路径(即自定义重定向,类别页面,产品页面等)。当前路由存储在缓存中的memcached服务器上。一切都很好,直到我们在服务器上获得高负载。然后,我可能会从缓存中检索错误,甚至有时会发生404错误。另外运行需要5-10秒的报告导致整个服务器挂起与MemCached的ASP.Net MVC自定义路由处理程序
- 我应该使用自定义路由处理程序甚至开始?
这不是全部异步完成吗?
public IHttpHandler GetHttpHandler(RequestContext requestContext) { var _lock = new Object(); MvcHandler handler = null; var path = requestContext.HttpContext.Request.Path.ToLower().RemoveOutsideSlashes(); var qs = requestContext.HttpContext.Request.QueryString; List<Cache.RouteItem> items; lock (_lock) { var cache = new CacheManager(); items = cache.Routes; } if (!hasPermanentRedirect(path, qs, items, ref requestContext)) { // check for categories first handler = checkForCategory(path, items, ref requestContext); // check for product if (handler == null) handler = checkForProduct(path, items, ref requestContext); // check for webpage if (handler == null) handler = checkForWebPage(path, items, ref requestContext); } if (handler != null) return handler; return new MvcHandler(requestContext); }
难道我的理解对不对,你写你自己的'的HttpHandler '而不是在MVC堆栈中使用'RouteConfig'? –