2
Answers

Application_BeginRequest in Global.asax wont execute!!!

Photo of David McEleney

David McEleney

18y
6.2k
1

Hi guys,

I'm trying to get a Application_BeginRequest in Global.asax to execute but it wont.

My Global.asax looks something like this:

<%
@ Application Language="C#" %>
<%
@ Import Namespace="System.IO" %>
<%
@ Import Namespace="System.Collections.Generic" %>
<%
@ Import Namespace="System.Globalization" %>
<%
@ Import Namespace="System.Xml" %>
<%
@ Import Namespace="System.Reflection" %>
<%
@ Import Namespace="System.Threading" %>
<%
@ Import Namespace="System.Web" %>

<script
runat="server">
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpCookie cookie = Request.Cookies["vizor"];
if (cookie != null)
{
String culture = cookie.Values["culture"].ToString();
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
}
}

// Other methods go here

</script>

Does anyone have any suggestions as to why it wont execute? I dont have any event handlers set up, and dont know if / where i have to.

Please advise!!!

David

Answers (2)

0
Photo of Vulpes
NA 96k 2.6m 12y
Well, you could generate such an ID with code such as this:

       string evt = "COM";
       int id = 100;
       DateTime dt = DateTime.Now;
       string uniqueID = String.Format("{0}{1:D2}{2:D2}{3}", evt, dt.Day, dt.Month, id);

Notice that you'll need to allow 2 digits for the month if October, November and December are to be catered for.

How unique this is going to be will depend, of course, on how unique the 'id' component is relative to the other components.