- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在 Umbraco 中触发 BeginRequest 事件,但它不起作用。其余代码工作正常。
public class ApplicationEventHandler : IApplicationEventHandler
{
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { }
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { }
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
umbracoApplication.BeginRequest += umbracoApplication_BeginRequest;
BundleConfig.RegisterBundles(BundleTable.Bundles);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
}
void umbracoApplication_BeginRequest(object sender, EventArgs e)
{
// Create HttpApplication and HttpContext objects to access
// request and response properties.
UmbracoApplicationBase application = (UmbracoApplicationBase)sender;
HttpContext context = application.Context;
if (context.Response.Cookies[Const.LANGUAGE_COOKIE_NAME] == null)
{
context.Response.Cookies.Add(new HttpCookie(Const.LANGUAGE_COOKIE_NAME, Thread.CurrentThread.CurrentUICulture.Name));
return;
}
//cookie exists already
else
{
//if no 404
if (UmbracoContext.Current.PublishedContentRequest != null && !UmbracoContext.Current.PublishedContentRequest.Is404)
{
//cookie value different than the current thread: user switched language.
if (context.Response.Cookies[Const.LANGUAGE_COOKIE_NAME].Value != Thread.CurrentThread.CurrentUICulture.Name)
{
//we set the cookie
context.Response.Cookies[Const.LANGUAGE_COOKIE_NAME].Value = Thread.CurrentThread.CurrentUICulture.Name;
}
}
}
}
}
你知道为什么它不起作用吗?我正在使用 umbraco 7,本地 IIS(不是 express),我无法在函数 umbracoApplication_BeginRequest 中记录消息。
最佳答案
这就是我能够在 Umbraco 7.1.2 实例中附加到 BeginRequest 的方式。首先创建一个继承自 UmbracoApplication 的新类(参见下面的示例),然后更新您的 global.asax 以继承您的新类。
public class MyUmbracoApplication : Umbraco.Web.UmbracoApplication
{
private void Application_BeginRequest(object sender, EventArgs e)
{
/* Your code here */
}
}
关于c# - Umbraco 应用程序 BeginRequest 从未被解雇,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31189884/
我创建了一个HttpModule: using System; using System.Web; public class TestModule : IHttpModule { public
我创建了一个HttpModule: using System; using System.Web; public class TestModule : IHttpModule { public
我必须测试有关调用阻止和识别的信息。所以我按照下面的步骤。 (1) 在我的项目中从 [File] > [New] > [Target] 创建一个 Call Directory Extension。 (
我想在 Umbraco 中触发 BeginRequest 事件,但它不起作用。其余代码工作正常。 public class ApplicationEventHandler : IApplication
我已经开始使用New Relic来监控http://alternativeto.net的性能这是一个相当大的网站。 我注意到,他们报告为“TransferRequestHandler”的方法花费了大量
我正在尝试向 .NET Mvc 应用程序中的每个请求添加一些请求上下文信息。我为此目的使用 LogicalCallContext,因为我的请求有时会调用异步任务。但是,我发现在 BeginReques
我有一个 http 模块,但自从迁移应用程序后,.NET 4 一直在经历一些奇怪的行为。 BeginRequest 事件不会在某些请求上触发(但会在其他请求上触发)- 到目前为止,我还没有设法确定何时
我们有一个 Web 应用程序,它运行在 6 个 Web 服务器上,HAProxy 作为负载均衡器。我们使用网络部署在所有网络服务器上同步我们的 IIS 和应用程序。从 1 月开始,一些客户开始报告应用
我正在使用一种有点自制的用户身份验证方法。对用户进行身份验证后,在 C# 中设置身份验证票证。 FormsAuthenticationTicket authenticationTicket = new
我的印象是静态文件(CSS、图像、@font-face 文件等)完全绕过了 ASP.NET,直接由 IIS 提供服务。 但是,每个 HTTP 请求都会调用我的 BeginRequest 事件处理程序,
我正在使用 CA 的 Identity Minder 在现有网站中实现新的 ASP.NET Identity 2.0 框架,该框架主要使用 Request.ServerVariables 来支持所有控
对于来自客户端的给定 HTTP 请求,ASP.NET HttpApplication 的 BeginRequest 和 EndRequest 是否总是发生在完全相同的线程上? 我问的原因是我看到一些非
我正在运行 VS 2008 和 .NET 3.5 SP1。 我想在 HttpModule 中实现命中跟踪在我的 ASP.NET 应用程序中。很简单,我想。然而,BeginRequest我的事件 Htt
我的应用程序中有一些代码需要在每个请求上执行,在执行任何其他操作之前 (甚至在身份验证之前)。到目前为止,我一直在使用 Application_BeginRequest我的 Global.asax 中
我的问题类似于但不完全相同: Why can't my host (softsyshosting.com) support BeginRequest and EndRequest event hand
我们有两个 Web 应用程序(Azure Web 角色),它们在 System.Web.HttpApplication.BeginRequest 期间都会遇到偶尔的长时间延迟(40 到 60 秒)。我
我们有一个 URLRewriting 模块,它在 BeginRequest 事件方法中使用 Response.Redirect 来更改目标页面。 使用 Server.Transfer 或 Server
我是一名优秀的程序员,十分优秀!