【问题标题】:Unable to debug httpModule of a sitefinity site hosted in IIS 8.5 using Visual Studio 2013无法使用 Visual Studio 2013 调试 IIS 8.5 中托管的 sitefinity 站点的 httpModule
【发布时间】:2015-12-23 23:24:51
【问题描述】:

我正在尝试使用 Visual Studio 2013 调试托管在 IIS 8.5 中的 sitefinity 网站的 httpModule。我正在使用 Sitefinity 8.1 进行网站开发。

到目前为止我所做的事情:

  1. 在 sitefinity 站点的根文件夹下创建了一个 httpModule。代码如下:
public class UserRoleHttpModule : IHttpModule
{            
    public void Init(HttpApplication application)
    {
        application.PostAuthenticateRequest +=
            (new EventHandler(this.PostAuthenticateRequest));
    }

    private void PostAuthenticateRequest(Object source,
                                         EventArgs e)
    {
        UserManager userManager = UserManager.GetManager();
        RoleManager roleManager = RoleManager.GetManager(SecurityManager.ApplicationRolesProviderName);
        roleManager.Provider.SuppressSecurityChecks = true;

        string[] rolesToAdd = new string[] {"BackendUsers"};

        if (userManager.UserExists("rahuln"))
        {
            User user = userManager.GetUser("rahuln");

            foreach (var roleName in rolesToAdd)
            {
                if (roleManager.RoleExists(roleName))
                {
                    Role role = roleManager.GetRole(roleName);
                    roleManager.AddUserToRole(user, role);
                }
            }
        }

        roleManager.SaveChanges();
        roleManager.Provider.SuppressSecurityChecks = false;
    }          

    public void Dispose()
    {
    }
}
  1. webconfig下注册模块
<modules runAllManagedModulesForAllRequests="true">        
            <remove name="UserRoleHttpModule" />
            <add name="UserRoleHttpModule" type="SitefinityWebApp.UserRoleHttpModule"/>
</modules>

现在,当我从 IIS 运行页面并在 Visual Studio 中使用 w3wp.exe 执行“附加到进程”时。我在 httpModule 中的断点从来没有受到影响。我尝试构建解决方案,构建成功。

任何帮助将不胜感激。

谢谢

【问题讨论】:

  • 项目是否处于调试模式? web.config 中是否编译 debug="true"?
  • 有人可以删除这个吗,我尝试输入回车并提交了我的评论。我将我的问题移到了答案中,以便我可以应用格式。

标签: asp.net visual-studio-2013 httpmodule sitefinity iis-8.5


【解决方案1】:

您确定 HttpModule 正在执行,以验证将以下内容添加到 PostAuthenticateRequest,如果是,它应该重定向到 microsoft.com。

HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Redirect("http://www.microsoft.com");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    • 2014-12-25
    • 2015-12-13
    • 2015-02-23
    • 2019-01-26
    • 1970-01-01
    相关资源
    最近更新 更多