public override void ExecuteResult(Routing.SwiftRouteData routeData) { var filepath = AppDomain.CurrentDomain.BaseDirectory + @"Views\" + routeData.RouteValue["controller"] + "\\" + routeData.RouteValue["action"] + ".html"; var fileContent = Engine.Razor.RunCompile(File.ReadAllText(filepath), filepath, null, Data); HttpResponse response = HttpContext.Current.Response; response.ContentType = "text/html"; response.Write(fileContent); }
public override void ExecuteResult(Routing.SwiftRouteData routeData) { //var filepath = AppDomain.CurrentDomain.BaseDirectory + @"Views\" + routeData.RouteValue["controller"]; //这里必须是虚拟路径 var velocity = new VelocityHelper(string.Format("~/Views/{0}/", routeData.RouteValue["controller"])); // 绑定实体model velocity.Put("model", Data); // 显示具体html HttpResponse response = HttpContext.Current.Response; response.ContentType = "text/html"; velocity.Display(string.Format("{0}.cshtml", routeData.RouteValue["action"].ToString())); }
public override void ExecuteResult(Routing.SwiftRouteData routeData) { HttpResponse response = HttpContext.Current.Response; response.ContentType = "text/html"; //取当前view页面的物理路径 var path = AppDomain.CurrentDomain.BaseDirectory + "Views/" + routeData.RouteValue["controller"] + "/" + routeData.RouteValue["action"] + ".html"; var templateData = string.Empty; using (var fsRead = new FileStream(path, FileMode.Open)) { int fsLen = (int)fsRead.Length; byte[] heByte = new byte[fsLen]; int r = fsRead.Read(heByte, 0, heByte.Length); templateData = System.Text.Encoding.UTF8.GetString(heByte); } response.Write(templateData); }
public override void ExecuteResult(Routing.SwiftRouteData routeData) { HttpResponse response = HttpContext.Current.Response; if (!String.IsNullOrEmpty(ContentType)) { response.ContentType = ContentType; } else { response.ContentType = "application/json"; } if (ContentEncoding != null) { response.ContentEncoding = ContentEncoding; } JavaScriptSerializer jss = new JavaScriptSerializer(); var json = jss.Serialize(Data); response.Write(json); }
public override void ExecuteResult(Routing.SwiftRouteData routeData) { HttpResponse response = HttpContext.Current.Response; if (!string.IsNullOrEmpty(ContentType)) { response.ContentType = ContentType; } else { response.ContentType = "text/html"; } if (ContentEncoding != null) { response.ContentEncoding = ContentEncoding; } if (Content != null) { response.Write(Content); } }