public JsonResult GetLinks() { var links = _requestHandlerInfo.GetRequestHandlerUrlInfos() .Select(h => { var methods = string.Join(',', _requestHandlerInfo.GetAreaInfos().SelectMany(a => a.Handlers) .Single(ha => ha.MethodInfo == h.Key).SupportedHttpMethods ?? new string[0]); return(new { Url = h.Value, HttpMethods = methods, Type = h.Key.DeclaringType.FullName }); }) .Where(h => !(!h.HttpMethods.IsNullOrEmpty() && !h.HttpMethods.ToLower().Contains("get"))) .Select(h => new { h.Type, h.Url }) .OrderBy(i => i.Url) .GroupBy(h => h.Type) .Select(h => new { h.Key, links = h.Select(l => l.Url) }); return(Json(links)); }
// GET: Manage/RequestAuthorizationRules/Create public IActionResult Create() { ViewData["Handlers"] = new SelectList( _requestHandlerInfo.GetRequestHandlerUrlInfos() .Select(h => { var methods = string.Join(',', _requestHandlerInfo.GetAreaInfos().SelectMany(a => a.Handlers) .Single(ha => ha.MethodInfo == h.Key).SupportedHttpMethods ?? new string[0]); return new { Url = $"{h.Value}{(!methods.IsNullOrEmpty() ? $" ({methods})" : null)}", Info = $"{(h.Key.GetCustomAttribute(typeof(RequestHandlerIdentificationAttribute)) as RequestHandlerIdentificationAttribute)?.UniqueKey}|{h.Key.DeclaringType.FullName}|{h.Key.ToString()}", Type = h.Key.DeclaringType }; }).OrderBy(i=>i.Url), "Info", "Url", null, "Type"); return View(); }