コード例 #1
0
ファイル: UrlUtil.cs プロジェクト: twislyn/Moon.Mvc
        public static string Action2 <T>(string method)
            where T : BaseController
        {
            var Request        = HttpContext.Current.Request;
            var baseURL        = Request.Url.Scheme + "://" + Request.Url.Authority;
            var userDefineName = UrlRouteCenter.GetUserDefineName <T>();
            var url            = baseURL + "/" + userDefineName + "/" + method + GlobalData.REQUST_SUFFIX;

            return(url);
        }
コード例 #2
0
        public override void Response(HttpContext context, string controllerFullName, string methodName, object model, Dictionary <string, object> viewData)
        {
            string tType          = TempateEngineType.ToString();
            string virtualPath    = null;
            string controllerName = UrlRouteCenter.GetUserDefineName(controllerFullName);
            var    basString      = "~/Views/" + controllerName + "/" + methodName;

            if (string.IsNullOrEmpty(TemplateVirtualPath))
            {
                if (IsMoblieRquest(context))
                {
                    virtualPath = basString + ".Mobile." + tType;
                    var str = context.Server.MapPath(virtualPath);
                    if (File.Exists(str) == false)
                    {
                        virtualPath = basString + "." + tType;
                    }
                }
                else
                {
                    virtualPath = basString + ".PC." + tType;
                    var str = context.Server.MapPath(virtualPath);
                    if (File.Exists(str) == false)
                    {
                        virtualPath = basString + "." + tType;
                    }
                }
            }
            else
            {
                virtualPath = this.TemplateVirtualPath;
            }
            string result = null;

            result = RenderUtil.RenderAspx(context, virtualPath, model, viewData);
            SetResponseEncoding(context);
            context.Response.Write(result);
            context.Response.Flush();
            // context.Response.End();//2015年9月13日15:02:52
        }