Click here to Skip to main content
15,917,176 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionAsp.net Session state Pin
Otekpo Emmanuel1-Sep-14 19:20
Otekpo Emmanuel1-Sep-14 19:20 
QuestionRe: Asp.net Session state Pin
Kornfeld Eliyahu Peter1-Sep-14 20:52
professionalKornfeld Eliyahu Peter1-Sep-14 20:52 
AnswerRe: Asp.net Session state Pin
Richard Deeming2-Sep-14 1:37
mveRichard Deeming2-Sep-14 1:37 
GeneralRe: Asp.net Session state Pin
Otekpo Emmanuel2-Sep-14 4:01
Otekpo Emmanuel2-Sep-14 4:01 
AnswerRe: Asp.net Session state Pin
ZurdoDev2-Sep-14 2:13
professionalZurdoDev2-Sep-14 2:13 
GeneralRe: Asp.net Session state Pin
Otekpo Emmanuel2-Sep-14 3:57
Otekpo Emmanuel2-Sep-14 3:57 
GeneralRe: Asp.net Session state Pin
ZurdoDev2-Sep-14 4:01
professionalZurdoDev2-Sep-14 4:01 
AnswerRe: Asp.net Session state Pin
sankarsan parida5-Sep-14 20:52
professionalsankarsan parida5-Sep-14 20:52 
QuestionHow to Restore Multiple .BAK files at a time in sql server 2008 anybody can tell me the correct way Pin
Member 1104982531-Aug-14 22:30
Member 1104982531-Aug-14 22:30 
SuggestionRe: How to Restore Multiple .BAK files at a time in sql server 2008 anybody can tell me the correct way Pin
Kornfeld Eliyahu Peter31-Aug-14 22:50
professionalKornfeld Eliyahu Peter31-Aug-14 22:50 
GeneralRe: How to Restore Multiple .BAK files at a time in sql server 2008 anybody can tell me the correct way Pin
Member 1104982531-Aug-14 23:10
Member 1104982531-Aug-14 23:10 
QuestionSuggestions for ways to store secret data in a html file Pin
jkirkerx30-Aug-14 16:51
professionaljkirkerx30-Aug-14 16:51 
AnswerRe: Suggestions for ways to store secret data in a html file Pin
Anurag Gandhi31-Aug-14 10:13
professionalAnurag Gandhi31-Aug-14 10:13 
GeneralRe: Suggestions for ways to store secret data in a html file Pin
jkirkerx31-Aug-14 10:26
professionaljkirkerx31-Aug-14 10:26 
GeneralRe: Suggestions for ways to store secret data in a html file Pin
jkirkerx31-Aug-14 11:31
professionaljkirkerx31-Aug-14 11:31 
QuestionHow to Notify change while inactive of web site developed by ASP.Net Pin
Tridip Bhattacharjee28-Aug-14 21:44
professionalTridip Bhattacharjee28-Aug-14 21:44 
i use sql dependency related code in globa.asax file to detect db change notification. i just start the sql dependency from Application_Start event in global.asax file and also called a function which monitor db table change and send notification. every thing is working fine if

application pool

is running means at least one user is on our web site and at the same time db table change occur.

suppose when db change occur and at the same time

application pool

is idle or no visitor is visiting our web site then change detection routine is not getting invoke automatically.

here is the code
C#
protected void Application_Start(Object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlDependency.Stop(connectionString);
            System.Data.SqlClient.SqlDependency.Start(connectionString);
            RegisterNotification();
        }
        static SqlDependency dep;
        private static void RegisterNotification()
        {
            string tmpdata = "";
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "SELECT ActivityDate FROM [bba-reman].ContentChangeLog";
                    dep = new SqlDependency(cmd);
                    dep.OnChange += new OnChangeEventHandler(OnDataChange);
                    SqlDataReader dr = cmd.ExecuteReader();
                    {
                        while (dr.Read())
                        {
                            if (dr[0] != DBNull.Value)
                            {
                                tmpdata = dr[0].ToString();
                            }
                        }
                    }

                    dr.Dispose();
                    cmd.Dispose();
                }
            }
            finally
            {
                //SqlDependency.Stop(connStr);
            }

        }

        static void OnDataChange(object sender, SqlNotificationEventArgs e)
        {
            SqlDependency dep = sender as SqlDependency;
            dep.OnChange -= new OnChangeEventHandler(OnDataChange);
            SiteSearch.CreateIndex(false);
            RegisterNotification();
        }

        protected void Application_End(Object sender, EventArgs e)
        {
            System.Data.SqlClient.SqlDependency.Stop(connectionString);
        }

just discuss how could i restructure my routine as a result

OnDataChange()

will fire if application pool is idle or if no visitor is visiting my web site.

one guy told me very vaguely

you are use the thread from the thread poll for the first request. as asp.net recycles threads and actions like redirect abort the thread, you need a safer thread to perform your action one. so in application start you should start a background thread to handle the dependency.

so please some one discuss this issue in details as a result my above code should run perfectly when no visitor is visiting our web site any page. thanks
tbhattacharjee

QuestionIssue regarding implementing SQL Dependency in Application_Start event Pin
Tridip Bhattacharjee28-Aug-14 4:26
professionalTridip Bhattacharjee28-Aug-14 4:26 
QuestionNo relevant Source lines in visual studio 2012 Pin
swathi(MCA)27-Aug-14 19:54
swathi(MCA)27-Aug-14 19:54 
AnswerRe: No relevant Source lines in visual studio 2012 Pin
Richard MacCutchan27-Aug-14 22:23
mveRichard MacCutchan27-Aug-14 22:23 
AnswerRe: No relevant Source lines in visual studio 2012 Pin
Kornfeld Eliyahu Peter27-Aug-14 22:35
professionalKornfeld Eliyahu Peter27-Aug-14 22:35 
QuestionFlipKart Api Sample Code Pin
harshbollu26-Aug-14 19:53
harshbollu26-Aug-14 19:53 
AnswerRe: FlipKart Api Sample Code Pin
raju melveetilpurayil2-Sep-14 14:14
professionalraju melveetilpurayil2-Sep-14 14:14 
AnswerRe: FlipKart Api Sample Code Pin
Sibeesh KV29-Sep-14 1:27
professionalSibeesh KV29-Sep-14 1:27 
Questionhow to use datapager with repeater in asp.net Pin
harshbollu26-Aug-14 19:40
harshbollu26-Aug-14 19:40 
AnswerRe: how to use datapager with repeater in asp.net Pin
Richard Deeming27-Aug-14 2:36
mveRichard Deeming27-Aug-14 2:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.