【问题标题】:Privatizing a BlogEngine.Net Installation私有化 BlogEngine.Net 安装
【发布时间】:2010-09-06 06:04:42
【问题描述】:

我有一个需要私有化的 blogengine.net 安装。

我目前正在进行研究工作,但在满足某些条件之前,我必须将我的博客/期刊保密。

如何将我的 blogEngine.net 安装私有化,以便读者必须登录才能阅读我的帖子?

【问题讨论】:

    标签: c# .net asp.net blogs


    【解决方案1】:

    发件人:BlogEngine.NET 2.5 - Private Blogs

    如果您进入控制面板、用户选项卡、角色子选项卡(右侧),在右侧工具区域的“匿名”中,将鼠标悬停在上面并选择“权限”。

    您现在位于匿名角色的权限页面上。取消选中所有内容,尤其是“查看公共帖子”。但是,您确实需要至少检查一项,否则一切都会恢复为默认值。例如,您可以选中“查看帖子评分”。然后保存。

    然后,任何未登录的人都应自动重定向到登录页面,无论他们尝试从哪个页面进入网站。

    【讨论】:

      【解决方案2】:

      我使用这个扩展。只需将文件保存为 RequireLogin.cs 在您的 App_Code\Extensions 文件夹中,并确保扩展已激活。

      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");
              }
          }
      }
      

      【讨论】:

        【解决方案3】:

        lomaxx 的回答无效,所以我决定避免让 blogengine.net 为读者执行身份验证。

        在 iis 上,我禁用了匿名访问,并在 win2k3 用户列表中添加了一个访客用户。

        【讨论】:

          【解决方案4】:

          我们创建了一个简单的工具,允许某些用户根据他们的 ASP.NET 成员角色访问某些帖子,以达到类似的结果。

          http://blog.lavablast.com/post/2008/08/BlogEnginenet-Post-Security.aspx

          【讨论】:

            【解决方案5】:

            我认为可以通过执行以下操作在 web 配置文件中执行此操作:

            <system.web>
                <authorization>
                  <allow roles="Admin" />
                  <deny users="*" />
                </authorization>
            </system.web>
            

            【讨论】:

            猜你喜欢
            • 2011-12-01
            • 1970-01-01
            • 2013-12-03
            • 1970-01-01
            • 2014-03-29
            • 1970-01-01
            • 1970-01-01
            • 2021-05-27
            • 2019-05-26
            相关资源
            最近更新 更多