码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2016-08-09 20:35:13      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:

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
                }
            };

        }

 

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

标签:

原文地址:http://www.cnblogs.com/zhshlimi/p/5754382.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!