Click here to Skip to main content
15,910,661 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionNeeds assistance in displaying data in Tree view Pin
Skanless9-Jan-07 10:28
Skanless9-Jan-07 10:28 
QuestionASP.NET 2.0 and AJAX Pin
RX Maverick9-Jan-07 10:03
RX Maverick9-Jan-07 10:03 
AnswerRe: ASP.NET 2.0 and AJAX Pin
Christian Graus9-Jan-07 12:19
protectorChristian Graus9-Jan-07 12:19 
QuestionpageBaseType Pin
Brendan Vogt9-Jan-07 8:57
Brendan Vogt9-Jan-07 8:57 
AnswerRe: pageBaseType Pin
Christian Graus9-Jan-07 12:28
protectorChristian Graus9-Jan-07 12:28 
AnswerRe: pageBaseType Pin
Mike Ellison9-Jan-07 12:33
Mike Ellison9-Jan-07 12:33 
GeneralRe: pageBaseType Pin
Brendan Vogt11-Jan-07 7:26
Brendan Vogt11-Jan-07 7:26 
Questionhow to capture content markup within an httpmodule? [modified] Pin
jszpila9-Jan-07 8:44
jszpila9-Jan-07 8:44 
Hello all,
I currently have an httpmodule that extracts various information regarding the response that is being sent to the client. One thing I want to implement is a count of how many external files (.js or .css) are being included in the page. I have a regex function for this, but the problem I'm having is I can't quite figure out how to access the markup that is being sent to the client. Here's most of what I have so far:
public class ResponseSizeHttpModule : IHttpModule
   {

       public void Init(HttpApplication application)
       {
           if (Convert.ToBoolean(ConfigurationManager.AppSettings["CheckResponseSize"]) == true)
           {
               application.BeginRequest += new EventHandler(this.AddFilter);
               application.EndRequest += new EventHandler(this.ResponseMessage);
           }
       }

       private void AddFilter(Object source, EventArgs e)
       {
           HttpApplication application = (HttpApplication)source;
           application.Response.Filter = new CounterClass(application.Response.Filter);
       }

       private void ResponseMessage(Object source, EventArgs e)
       {
           HttpApplication application = (HttpApplication)source;
           long lPageSize = application.Response.Filter.Length;
           long lRespLimit = Convert.ToInt64(ConfigurationManager.AppSettings["ResponseLimitBytes"]);

           if (lPageSize > lRespLimit)
           {
               string strResponse = ""; //get the content of the response here!
               int intNumIncludes = CountIncludes(strResponse);
               //StringBuilder sbAlertMsg = new StringBuilder();
               //build message here
               //HttpContext.Current.Response.Write(sbAlertMsg);
           }
       }

       private int CountIncludes(string strResponse)
       {
           Regex reScripts = new Regex(".js|.css", RegexOptions.IgnoreCase);

           return reScripts.Matches(strResponse).Count;
       }

       public void Dispose(){}
   }


The bolded part is where I'd like to try to do this. I'm pretty new to httpmodules and the like so any suggestions on more effective methods are welcome, as would any other help.

Thanks in advance!

-------------------
abort, retry, fail?

AnswerRe: how to capture content markup within an httpmodule? Pin
Mike Ellison9-Jan-07 12:29
Mike Ellison9-Jan-07 12:29 
GeneralRe: how to capture content markup within an httpmodule? Pin
jszpila10-Jan-07 6:24
jszpila10-Jan-07 6:24 
QuestionWeb Service Pin
Rahithi9-Jan-07 8:02
Rahithi9-Jan-07 8:02 
AnswerRe: Web Service Pin
ednrgc9-Jan-07 8:24
ednrgc9-Jan-07 8:24 
GeneralRe: Web Service Pin
Rahithi9-Jan-07 8:46
Rahithi9-Jan-07 8:46 
GeneralRe: Web Service Pin
ednrgc9-Jan-07 8:48
ednrgc9-Jan-07 8:48 
GeneralRe: Web Service Pin
Rahithi9-Jan-07 8:55
Rahithi9-Jan-07 8:55 
QuestionSecurity Issue Pin
alexfromto9-Jan-07 7:02
alexfromto9-Jan-07 7:02 
AnswerRe: Security Issue Pin
ednrgc9-Jan-07 7:13
ednrgc9-Jan-07 7:13 
GeneralRe: Security Issue Pin
alexfromto9-Jan-07 7:47
alexfromto9-Jan-07 7:47 
QuestionAnyone know why a multi-threaded ASP.NET application would work in VS2005, but not on the production environment? Pin
travich9-Jan-07 6:36
travich9-Jan-07 6:36 
AnswerRe: Anyone know why a multi-threaded ASP.NET application would work in VS2005, but not on the production environment? Pin
ednrgc9-Jan-07 7:12
ednrgc9-Jan-07 7:12 
GeneralRe: Anyone know why a multi-threaded ASP.NET application would work in VS2005, but not on the production environment? Pin
travich9-Jan-07 8:30
travich9-Jan-07 8:30 
GeneralRe: Anyone know why a multi-threaded ASP.NET application would work in VS2005, but not on the production environment? Pin
ednrgc9-Jan-07 8:44
ednrgc9-Jan-07 8:44 
GeneralRe: Anyone know why a multi-threaded ASP.NET application would work in VS2005, but not on the production environment? Pin
travich9-Jan-07 9:01
travich9-Jan-07 9:01 
GeneralRe: Anyone know why a multi-threaded ASP.NET application would work in VS2005, but not on the production environment? Pin
travich9-Jan-07 9:36
travich9-Jan-07 9:36 
Questionusing Sessions between webservice and aspx Pin
guygo9-Jan-07 6:16
guygo9-Jan-07 6:16 

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.