私有化BlogEngine.Net安装
时间:2020-03-05 18:40:59 来源:igfitidea点击:
我有一个需要私有化的blogengine.net安装。
目前,我正在从事研究工作,但是在满足某些条件之前,我必须保持博客/期刊的私密性。
如何私有化我的blogEngine.net安装,以便读者必须登录才能阅读我的帖子?
解决方案
回答
我认为可以通过执行以下操作在Web配置文件中执行此操作:
<system.web> <authorization> <allow roles="Admin" /> <deny users="*" /> </authorization> </system.web>
回答
lomaxx的答案无效,因此我决定避免让Blogengine.net对读者执行身份验证。
在iis上,我禁用了匿名访问,并将guest用户添加到了win2k3用户列表中。
回答
我们创建了一个简单的工具,该工具可以使某些用户根据其ASP.NET成员角色访问某些帖子,从而获得某种程度相似的结果。
http://blog.lavablast.com/post/2008/08/BlogEnginenet-Post-Security.aspx
回答
我用这个扩展名。只需将文件另存为App_Code \ Extensions文件夹中的RequireLogin.cs并确保扩展已激活。
using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using BlogEngine.Core; using BlogEngine.Core.Web.Controls; using System.Collections.Generic; /// <summary> /// Summary description for PostSecurity /// </summary> [Extension("Checks to see if a user can see this blog post.", "1.0", "<a href=\"http://www.lavablast.com\">LavaBlast.com</a>")] public class RequireLogin { static protected ExtensionSettings settings = null; public RequireLogin() { Post.Serving += new EventHandler<ServingEventArgs>(Post_Serving); ExtensionSettings s = new ExtensionSettings("RequireLogin"); // describe specific rules for entering parameters s.Help = "Checks to see if the user has any of those roles before displaying the post. "; s.Help += "You can associate a role with a specific category. "; s.Help += "All posts having this category will require that the user have the role. "; s.Help += "A parameter with only a role without a category will enable to filter all posts to this role. "; ExtensionManager.ImportSettings(s); settings = ExtensionManager.GetSettings("PostSecurity"); } protected void Post_Serving(object sender, ServingEventArgs e) { MembershipUser user = Membership.GetUser(); if(HttpContext.Current.Request.RawUrl.Contains("syndication.axd")) { return; } if (user == null) { HttpContext.Current.Response.Redirect("~/Login.aspx"); } } }