You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
2.0 KiB

@using System.Web.Caching;
@{
Page.Title = Blog.Title;
Layout = "~/themes/" + Blog.Theme + "/_Layout.cshtml";
DateTime lastModified = DateTime.MinValue;
if (string.IsNullOrEmpty(Blog.CurrentSlug))
{
Page.ShowPaging = true;
var posts = Blog.GetPosts(Blog.PostsPerPage);
foreach (var post in posts)
{
@RenderPage("~/themes/" + Blog.Theme + "/Post.cshtml", post);
}
if (posts.Any())
{
lastModified = posts.Max(p => p.LastModified);
}
Response.AddCacheItemDependency("posts");
Response.Cache.VaryByParams["page"] = true;
Response.Cache.VaryByParams["category"] = true;
}
else
{
Post post = Blog.IsNewPost ? new Post() : Blog.CurrentPost;
if (Blog.IsNewPost && !User.Identity.IsAuthenticated)
{
FormsAuthentication.RedirectToLoginPage();
}
if (post == null) { throw new HttpException(404, "Post not found"); }
Page.Title = post.Title;
lastModified = post.LastModified;
Response.AddCacheDependency(new CacheDependency(Server.MapPath("~/posts/" + post.ID + ".xml")));
@RenderPage("~/themes/" + Blog.Theme + "/Post.cshtml", post)
}
if (!Request.IsLocal)
{
Response.Cache.AppendCacheExtension("max-age=0");
Response.Cache.SetValidUntilExpires(true);
Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
Response.Cache.SetVaryByCustom("authenticated");
Response.Cache.VaryByParams["slug"] = true;
Response.AddCacheDependency(new CacheDependency(Server.MapPath("~/")));
Response.AddCacheDependency(new CacheDependency(Server.MapPath("~/scripts")));
Response.AddCacheDependency(new CacheDependency(Server.MapPath("~/css")));
Response.AddCacheDependency(new CacheDependency(Server.MapPath("~/themes/" + Blog.Theme)));
Blog.SetConditionalGetHeaders(lastModified, Context);
}
}