C#MVC路由配置 之 动态请求伪装静态Json来欺骗CND

public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
               name: "cdn",
               url: "style/{appVersion}/{appChannel}/{appOs}/{pageCode}/{resourceVersion}.json",
               defaults: new { controller = "App", action = "Style"  }
           );
            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Account", action = "Index", id = UrlParameter.Optional }
            );
        }
    }

 

 public JsonResult Style(string appVersion, string appChannel, string appOs, string pageCode,
            string resourceVersion)
        {
            var request = HttpContext.Request.QueryString;
            request = new NameValueCollection()
            {
                {"appVersion", appVersion},
                {"appChannel", appChannel},
                {"appOs", appOs},
                {"pageCode", pageCode},
                {"resourceVersion", resourceVersion}

            };

            var response = _appService.QueryAppConfig(request);

            //Response.Write(response);
            return new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new
                {
                    success = true,
                    content = response
                }
            };

        }

 

posted @ 2016-08-09 19:17  zslm___  阅读(402)  评论(0编辑  收藏  举报