473,322 Members | 1,232 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,322 software developers and data experts.

pre-process to ASP.NET...

I want to pre-process some of my pages using some custom code, then output
the ASP.NET page so the regular ASP.NET handler takes care of it. I'd like
for page caching, etc. to work as normal.

What's the best approach?

-Paul
Nov 18 '05 #1
6 1497
Hi,

I believe an HTTP module or custom code in global.asax would be what you are
looking for. In this article there are listed the HttpApplication events you
can wire handlers on (reusable HTTP module or app-specific code in
global.asax, both can get to the same events)
http://www.eggheadcafe.com/articles/20030211.asp

Here is an article about how to implement HTTP modules.
http://www.devx.com/vb2themax/Article/19901/0/page/1

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


"Paul Colton" <paul@nospam_colton.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I want to pre-process some of my pages using some custom code, then output
the ASP.NET page so the regular ASP.NET handler takes care of it. I'd like
for page caching, etc. to work as normal.

What's the best approach?

-Paul

Nov 18 '05 #2
I can write the HTTP module, but I can't figure out how to change the
filename, or content length, or content itself of the REQUEST, not of the
response. For example, what if I have a text file that contains macros that
I want to expand BEFORE ASP.NET processes the page?

Paul

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:O9**************@TK2MSFTNGP09.phx.gbl...
Hi,

I believe an HTTP module or custom code in global.asax would be what you are looking for. In this article there are listed the HttpApplication events you can wire handlers on (reusable HTTP module or app-specific code in
global.asax, both can get to the same events)
http://www.eggheadcafe.com/articles/20030211.asp

Here is an article about how to implement HTTP modules.
http://www.devx.com/vb2themax/Article/19901/0/page/1

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


"Paul Colton" <paul@nospam_colton.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I want to pre-process some of my pages using some custom code, then output
the ASP.NET page so the regular ASP.NET handler takes care of it. I'd like
for page caching, etc. to work as normal.

What's the best approach?

-Paul

Nov 18 '05 #3
Hi Paul,
Thanks for posting in the community!
From your description, you'd like to do some pre-process on a certain
ASP.NET web request?

In the former messages, Teemu Keiski has mentioned the means use the
"HttpModules". I thinkyou can also implement the same operations in the
HttpModules in the Application's Global object (Global.asax/
Global.asax.cs). There're also the same events in the Global object to help
you hook the web request's processing. For example:
protected void Application_BeginRequest(Object sender, EventArgs e)
{...}

protected void Application_EndRequest(Object sender, EventArgs e)
{...}

protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{...}

Then, if you want to some operations on the Request's data, you can
retrieve the Request object via
"HttpContext.Current.Request" , it has several members to help do some
modifications on it, such as:
HttpContext.Current.Request.InputStream;
HttpContext.Current.Request.FilePath

For more detailed info on the Global object and Request object, you may
view the following reference in MSDN:
#Global.asax File
http://msdn.microsoft.com/library/en...globalasaxfile.
asp?frame=true

#HttpRequest Class
http://msdn.microsoft.com/library/en...WebHttpRequest
ClassTopic.asp?frame=true

In addition, since you mentioned that
" what if I have a text file that contains macros that
I want to expand BEFORE ASP.NET processes the page"

Do you mean that you want to do some modification on the certain ASPX
page's page source before it is compiled and used to process the Request?
If so, the aspx( httpHandler) will be created at runtime by HandlerFactory,
though it is described behind the HttpModules in the ASP.NET's pipline, but
it is likely that it has been compiled and created( the instance) when the
certain hooked events(Request_Begin...) is fired. So I think as for such
situation, maybe you can consider implement a custom httphandler which will
deal with the certain kinds of request, then delegate the other detailed
processing behind that httphandler( it is just like a proxy), how do you
think of this?

Here're some tech references and articles on HttpHandlers:
#HttpHandlers
http://msdn.microsoft.com/library/en...handlers.asp?f
rame=true

#Implementing Front Controller in ASP.NET Using HTTPHandler
http://msdn.microsoft.com/library/en...ntControllerIn
ASP.asp?frame=true

And here are some other tech articles I've searched on the web:
#ASP.NET MVC Web-Tier
http://moncs.cs.mcgill.ca/people/hv/...gn/codagen.pdf

Hope they're helpful.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4
Then, if you want to some operations on the Request's data, you can
retrieve the Request object via
"HttpContext.Current.Request" , it has several members to help do some
modifications on it, such as:
HttpContext.Current.Request.InputStream;
HttpContext.Current.Request.FilePath
One problem is that InputStream and FilePath are both read-only properties,
so I can't change their values.
In addition, since you mentioned that
" what if I have a text file that contains macros that
I want to expand BEFORE ASP.NET processes the page"

Do you mean that you want to do some modification on the certain ASPX
page's page source before it is compiled and used to process the Request?
If so, the aspx( httpHandler) will be created at runtime by HandlerFactory, though it is described behind the HttpModules in the ASP.NET's pipline, but it is likely that it has been compiled and created( the instance) when the
certain hooked events(Request_Begin...) is fired. So I think as for such
situation, maybe you can consider implement a custom httphandler which will deal with the certain kinds of request, then delegate the other detailed
processing behind that httphandler( it is just like a proxy), how do you
think of this?


Can you explain this further? So let's say I want to pre-process the ASP.NET
source file before handing it over to asp.net, how would I 'delegate' my
updated file over to asp.net?
Nov 18 '05 #5
Hi Paul,

Thanks for your followup. I've done some further research on this issue and
here is some further infos maybe helpful to you:
1. As for how to modify the request content(stream) before it is processed
by the ASP.NET page handler, I think you can make use of the "Filter" for
the Request object. In ASP.NET both the Request and Response object has a
member named "filter" which is a instance of stream for class derieved from
stream, we can use "Filter" to do some certain modification on the Request
before it being processed or on the Response after it has been processed.
As for your situation, I think the Request filter is what you needed , and
you need to use it in a HttpModule or in the Global
object(global.asax/global.asax.cs) 's certain event such as BeginRequest...
For detailed info and example, you can refer to the following tech
articles:

#HttpRequest.Filter Property
http://msdn.microsoft.com/library/en...webhttprequest
classfiltertopic.asp?frame=true

#Filtering HTTP Requests with .NET
http://www.ondotnet.com/pub/a/dotnet...ttpfilter.html

2. I also found that in ASP.NET it has provided the URL Rewriting function
which allow use to do some certain redirect actions before the certain
request has been processed. I think this will be helpful if you'd like to
modify the request url path. Here is also a tech article discussing this
topic:

#URL Rewriting with ASP.NET
http://www.codeproject.com/aspnet/URLRewriter.asp

Please check out the above items. If you still feel them not quite
suitable, please feel free to post here. I'll be willing to assit you on
further requests.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Nov 18 '05 #6
Filters can't alter the size of the request, but it looks like URL rewriting
may be my ticket. Thank you.

Paul

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Xp**************@cpmsftngxa07.phx.gbl...
Hi Paul,

Thanks for your followup. I've done some further research on this issue and here is some further infos maybe helpful to you:
1. As for how to modify the request content(stream) before it is processed
by the ASP.NET page handler, I think you can make use of the "Filter" for
the Request object. In ASP.NET both the Request and Response object has a
member named "filter" which is a instance of stream for class derieved from stream, we can use "Filter" to do some certain modification on the Request
before it being processed or on the Response after it has been processed.
As for your situation, I think the Request filter is what you needed , and
you need to use it in a HttpModule or in the Global
object(global.asax/global.asax.cs) 's certain event such as BeginRequest... For detailed info and example, you can refer to the following tech
articles:

#HttpRequest.Filter Property
http://msdn.microsoft.com/library/en...webhttprequest classfiltertopic.asp?frame=true

#Filtering HTTP Requests with .NET
http://www.ondotnet.com/pub/a/dotnet...ttpfilter.html

2. I also found that in ASP.NET it has provided the URL Rewriting function
which allow use to do some certain redirect actions before the certain
request has been processed. I think this will be helpful if you'd like to
modify the request url path. Here is also a tech article discussing this
topic:

#URL Rewriting with ASP.NET
http://www.codeproject.com/aspnet/URLRewriter.asp

Please check out the above items. If you still feel them not quite
suitable, please feel free to post here. I'll be willing to assit you on
further requests.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #7

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

Similar topics

21
by: Headless | last post by:
I've marked up song lyrics with the <pre> tag because it seems the most appropriate type of markup for the type of data. This results in inefficient use of horizontal space due to UA's default...
7
by: Alan Illeman | last post by:
How do I set several different properties for PRE in a CSS stylesheet, rather than resorting to this: <BODY> <PRE STYLE="font-family:monospace; font-size:0.95em; width:40%; border:red 2px...
2
by: Buck Turgidson | last post by:
I want to have a css with 2 PRE styles, one bold with large font, and another non-bold and smaller font. I am new to CSS (and not exactly an expert in HTML, for that matter). Is there a way to...
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
8
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
23
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.