473,388 Members | 1,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Filter output by using a HttpModule

I want to be able to implement a filter that manipulates the output from the
server... Maybe replacing some words, or highlighting a search string, or
some other fancy feature...

I want to make this code reusable to all my applications, and by making this
as a HttpModule I can implement this feature on existing .Net applications
by editing the we.config and nothing else...

My problem is that that I can't get this to work.

Some pseudo-code:

public class PostProcessingModule : System.Web.IHttpModule {
public void Init(System.Web.HttpApplication context) {
// What event should i use ....
// How do I reference the output and replace values
// How do I write my own manipulated stuff to the client
}

public void Dispose() {}

}
Nov 18 '05 #1
4 1788
example here

http://flaky.dk/aspnet_httpmodule_charrewrite.html

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP

"Thomas" <ne**********@opcon.no> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
I want to be able to implement a filter that manipulates the output from the server... Maybe replacing some words, or highlighting a search string, or
some other fancy feature...

I want to make this code reusable to all my applications, and by making this as a HttpModule I can implement this feature on existing .Net applications
by editing the we.config and nothing else...

My problem is that that I can't get this to work.

Some pseudo-code:

public class PostProcessingModule : System.Web.IHttpModule {
public void Init(System.Web.HttpApplication context) {
// What event should i use ....
// How do I reference the output and replace values
// How do I write my own manipulated stuff to the client
}

public void Dispose() {}

}

Nov 18 '05 #2
Thx!

This solves my problem... almost ;-)

What if I want to implement more than one filter... lets say I have a
SearchHighlightModule and a WordCensorModule ... The Response object can
only supprt one filter... I was hoping to be able to do this directly from
the httpmodule, but maybe that is impossible...

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:Ot**************@TK2MSFTNGP10.phx.gbl...
example here

http://flaky.dk/aspnet_httpmodule_charrewrite.html

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP

"Thomas" <ne**********@opcon.no> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
I want to be able to implement a filter that manipulates the output from

the
server... Maybe replacing some words, or highlighting a search string, or some other fancy feature...

I want to make this code reusable to all my applications, and by making

this
as a HttpModule I can implement this feature on existing .Net applications by editing the we.config and nothing else...

My problem is that that I can't get this to work.

Some pseudo-code:

public class PostProcessingModule : System.Web.IHttpModule {
public void Init(System.Web.HttpApplication context) {
// What event should i use ....
// How do I reference the output and replace values
// How do I write my own manipulated stuff to the client
}

public void Dispose() {}

}


Nov 18 '05 #3
I figured it out... still using Response.Filter

HttpResponse res = HttpContext.Current.Response;

if ( res.ContentType == "text/html" ) {
res.Filter = new CensorFilter(res.Filter);
res.Filter = new HightLightFilter(res.Filter);
}

In fact there was nothing to figure out... It just works :-D
"Thomas" <ma******@opcon.no> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
Thx!

This solves my problem... almost ;-)

What if I want to implement more than one filter... lets say I have a
SearchHighlightModule and a WordCensorModule ... The Response object can
only supprt one filter... I was hoping to be able to do this directly from
the httpmodule, but maybe that is impossible...

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:Ot**************@TK2MSFTNGP10.phx.gbl...
example here

http://flaky.dk/aspnet_httpmodule_charrewrite.html

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP

"Thomas" <newsma******@opcon.no> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
I want to be able to implement a filter that manipulates the output
from
the
server... Maybe replacing some words, or highlighting a search string, or some other fancy feature...

I want to make this code reusable to all my applications, and by
making this
as a HttpModule I can implement this feature on existing .Net

applications by editing the we.config and nothing else...

My problem is that that I can't get this to work.

Some pseudo-code:

public class PostProcessingModule : System.Web.IHttpModule {
public void Init(System.Web.HttpApplication context) {
// What event should i use ....
// How do I reference the output and replace values
// How do I write my own manipulated stuff to the client
}

public void Dispose() {}

}



Nov 18 '05 #4
Yes, you can do that. Or you can make seperate filters and force their
order of priority by their position in order in web.config.

Glad you have a resolution.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
"Thomas" <ma******@opcon.no> wrote in message
news:eD**************@TK2MSFTNGP12.phx.gbl...
I figured it out... still using Response.Filter

HttpResponse res = HttpContext.Current.Response;

if ( res.ContentType == "text/html" ) {
res.Filter = new CensorFilter(res.Filter);
res.Filter = new HightLightFilter(res.Filter);
}

In fact there was nothing to figure out... It just works :-D
"Thomas" <ma******@opcon.no> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
Thx!

This solves my problem... almost ;-)

What if I want to implement more than one filter... lets say I have a
SearchHighlightModule and a WordCensorModule ... The Response object can
only supprt one filter... I was hoping to be able to do this directly from
the httpmodule, but maybe that is impossible...

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:Ot**************@TK2MSFTNGP10.phx.gbl...
example here

http://flaky.dk/aspnet_httpmodule_charrewrite.html

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP

"Thomas" <newsma******@opcon.no> wrote in message
news:O8*************@TK2MSFTNGP11.phx.gbl...
> I want to be able to implement a filter that manipulates the output from the
> server... Maybe replacing some words, or highlighting a search
string, or
> some other fancy feature...
>
> I want to make this code reusable to all my applications, and by

making this
> as a HttpModule I can implement this feature on existing .Net

applications
> by editing the we.config and nothing else...
>
> My problem is that that I can't get this to work.
>
> Some pseudo-code:
>
> public class PostProcessingModule : System.Web.IHttpModule {
> public void Init(System.Web.HttpApplication context) {
> // What event should i use ....
> // How do I reference the output and replace values
> // How do I write my own manipulated stuff to the client
> }
>
> public void Dispose() {}
>
> }
>
>



Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jon Maz | last post by:
Hi All, I've been looking into options for URL Rewriting in .net, and to be honest, I haven't seen anything that's easier than the old Classic Asp solution with an ISAPI filter redirecting to an...
7
by: nail | last post by:
Folks, I develop a HttpModule and it works correct, but one problem is occurs. After I register the httpmodule in the web.config, my pages (not testing http://localhost/site but...
1
by: Brian Norman | last post by:
Hello Can anyone suggest a way to read the response (I want to write it to a file) in an HttpModule but without using a response filter? I can't see any other way to get at the response...
2
by: Simon-Pierre Jarry | last post by:
Hi, I created a custom HttpModule for managing the security of my application. in "Init" sub, I regsiter the events doing that : Public Sub Init(ByVal context As System.Web.HttpApplication)...
2
by: Daves | last post by:
think the subject says it all, my domain www.domain.com now is running asp.net but still gets requests to asp pages which were there on the old server. Can I create some global http filter to...
0
by: mpdoreilly | last post by:
Hi, I've a webservice that has several typical webmethods that clients call and get responses from. (Side note: The websriivce is actually to implement the server side of tr-069, the protocol...
2
by: Josh Naro | last post by:
I am writing a module that requires the entire output from a web app to perform its function. So, basically I need to be able to pull the entire output stream from the Response object. I've tried...
1
by: lu2vik | last post by:
Hi, I would like to change the outputstream from response in the EndRequest httpmodule event. I tried whith the Response.Filter properties it works in the BeginRequest but not in the...
2
by: Ken Fine | last post by:
I have a question about ASP.NET output caching. I want to use screen scraping as a temporary hack to pull in some complex Classic ASP-rendered content into some ASP.NET pages: protected String...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.