// GET: Default public ActionResult Index() { string html = MVCHelper.RenderViewToString(ControllerContext, "~/Views/Default/Index.cshtml", "hello"); System.IO.File.WriteAllText("d:/1.txt", html); return(View()); }
private void PageToStatic(long id) { var dto = newService.GetById(id); string html = MVCHelper.RenderViewToString(this.ControllerContext, "/Views/Home/Details.cshtml", dto); string path = Server.MapPath("~/static"); System.IO.File.WriteAllText(path + "\\" + id + ".html", html); }
private async Task CreateStaticPage(long taskId) { string res = await taskService.GetContentAsync(taskId); string html = MVCHelper.RenderViewToString(this.ControllerContext, @"~/Views/Task/Info.cshtml", (object)res); string path = HttpContext.Request.PhysicalApplicationPath; path = path + @"static\"; System.IO.File.WriteAllText(path + taskId + ".html", html); }
public void CreateStaticPages(long houseId) { HouseIndexModel model = new HouseIndexModel { Attachments = AttachmentService.GetById(houseId), House = HouseService.GetById(houseId), HousePics = HouseService.GetPics(houseId) }; var html = MVCHelper.RenderViewToString(this.ControllerContext, "~/Views/House/StaticIndex.cshtml", model); System.IO.File.WriteAllText(@"F:\code2020\asp.net-C-\asp.net基础\rentHouse\RentHouse\RentHouse\staticPages\" + houseId + ".html", html); }
private void CreateStaticPage(long houseId) { var house = houseService.GetById(houseId); var pics = houseService.GetPics(houseId); var attachments = attService.GetAttachments(houseId); HouseIndexViewModel model = new HouseIndexViewModel(); model.House = house; model.Pics = pics; model.Attachments = attachments; string html = MVCHelper.RenderViewToString(this.ControllerContext, @"~/Views/House/StaticIndex.cshtml", model); System.IO.File.WriteAllText("d:/1.txt", html); }
private void CreateStaticPage(long houseId) { var house = houseService.GetById(houseId); var pics = houseService.GetPics(houseId); var attachments = attachmentService.GetAttachments(houseId); HouseStaticModel model = new HouseStaticModel(); model.House = house; model.HousePics = pics; model.Attachments = attachments; string html = MVCHelper.RenderViewToString(this.ControllerContext, "~/Views/House/HouseStatic.cshtml", model); System.IO.File.WriteAllText(@"D:\项目代码\ZSZ\ZSZ.FrontWeb\" + houseId + ".html", html); }
private void CreateStaticPage(long houseId) { var house = houseService.GetById(houseId); var pics = houseService.GetPics(houseId); var attachments = attService.GetAttachments(houseId); HouseIndexViewModel model = new HouseIndexViewModel(); model.House = house; model.Pics = pics; model.Attachments = attachments; string html = MVCHelper.RenderViewToString(this.ControllerContext, @"~/Views/House/StaticIndex.cshtml", model); System.IO.File.WriteAllText(@"E:\Program\NET高级培训\NET掌上租\项目代码\HLX.ZSZ\HLX.ZSZ.FrontWebs\" + houseId + ".html", html); }
private void CreateStaticPage(long houseId) { var house = houseService.GetById(houseId); //获得图片信息 var pics = houseService.GetPics(houseId); List <AttachementDTO> atts = new List <AttachementDTO>(); var attachments = attService.GetAttachments(houseId); HouseIndexViewModel model = new HouseIndexViewModel(); model.House = house; model.Pics = pics; model.Attachments = attachments; string html = MVCHelper.RenderViewToString(this.ControllerContext, @"~/Views/House/StaticIndex.cshtml", model); //静态页面保存到网站的根目录下去,用房子Id命名 System.IO.File.WriteAllText(@"E:\DemoMVC\ZSZ\ZSZ.FrontWeb\" + houseId + ".html", html); }
/// <summary> /// 创建前台房子详情的页面静态化 /// </summary> /// <param name="houseId">房子的id</param> private void CreateStaticPage(long houseId) { var house = houseService.GetById(houseId); var pics = houseService.GetPics(houseId); var attachments = attService.GetAttachments(houseId); //由于静态化的类是前台的类,重新拷贝一个类到后台 HouseIndexViewModel model = new HouseIndexViewModel(); model.House = house; model.Pics = pics; model.Attachments = attachments; //由于静态化的是前台的房屋详情页面,不能跨程序集,在本项目中创建一个和前台房屋详情一样的cshtml string html = MVCHelper.RenderViewToString(this.ControllerContext, @"~/Views/House/StaticIndex.cshtml", model); //保存到前台文件夹中 System.IO.File.WriteAllText(@"D:\UserData\My Documents\Visual Studio 2015\Projects\ZSZ\ZSZ.FrontWeb\" + houseId + ".html", html); }
public ActionResult Index() { string cacheKey = "MainLinks"; // LinkDTO[] model =(LinkDTO[])HttpContext.Cache[cacheKey]; // LinkModel model = new LinkModel(); LinkModel model = (LinkModel)MemcacheMgr.Instance.GetValue(cacheKey); if (model == null) { model = new LinkModel(); model.Links = linkService.GetAll(); // HttpContext.Cache.Insert(cacheKey, model, null,DateTime.Now.AddMinutes(1),TimeSpan.Zero); MemcacheMgr.Instance.SetValue(cacheKey, model, TimeSpan.FromMinutes(1)); } string html = MVCHelper.RenderViewToString(ControllerContext, "~/Views/Main/Index.cshtml", model); System.IO.File.WriteAllText(@"D:\workspace\ZH\ZSZFrontWeb\1.html", html); return(View(model)); }