您的位置:首页 > 其它

生成静态化页面

2015-09-26 21:09 309 查看
string html = RPHelper.ParseRazor(HttpContext.Current, "~/NewsMgr/ViewNews.cshtml", new {
Title=title,Body=body
});
//从配置文件(web.config)中读取静态页生成路径
string newStaticDir = ConfigurationManager.AppSettings["NewsStaticDir"];
string fullPath = newStaticDir +categoryId + @"\" + id+".shtml";
string htmlDir = Path.GetDirectoryName(fullPath);
if (!Directory.Exists(htmlDir))//文件夹不存在,则创建
{
Directory.CreateDirectory(htmlDir);
}
File.WriteAllText(fullPath, html);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: