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

how to transfer a request to a different page in IHttpModule (isapi like) class

Hi,
I'm using IHttpModule class (added to GAC and machine.config) to get
requests of non existing pages in my web server and redirect them to
different pages, using the Context.Server.Transfer(Target) method.

i.e :
Original ==> http://myserver/notExist/HelloThere
to
Target ==> http://myserver/DoesExist/helloWorld.aspx

the problem is that the DoesExist application receive the request and
it's web.config shows the following error:

Configuration error:
"Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS."

because notExist is not an appliaction in the web server, what should i
do to eliminate this problem?

Thanks!

Daberelay.

Nov 19 '05 #1
8 1639
<da*******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi,
I'm using IHttpModule class (added to GAC and machine.config) to get
requests of non existing pages in my web server and redirect them to
different pages, using the Context.Server.Transfer(Target) method.

i.e :
Original ==> http://myserver/notExist/HelloThere
to
Target ==> http://myserver/DoesExist/helloWorld.aspx

the problem is that the DoesExist application receive the request and
it's web.config shows the following error:

Configuration error:
"Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS."

because notExist is not an appliaction in the web server, what should i
do to eliminate this problem?


Have you tried using Response.Redirect instead of Server.Transfer?
Server.Transfer is really meant to transfer from one HttpHandler to another,
and in your case, it seems that the handler doesn't exist (since the page
does not exist).

John Saunders
Nov 19 '05 #2
vbpj.com had a neat article on this about a year and half or two years ago.
Do a search on their site for "hierarchical url". It shows how to set up an
URL like:

mysite.com/dec/2004/28

to

mysite.com/pagehandler.aspx?id=12/28/2004

This is similar to what you want. And, there is sample code to download on
the site, if I remember correctly.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"da*******@gmail.com" wrote:
Hi,
I'm using IHttpModule class (added to GAC and machine.config) to get
requests of non existing pages in my web server and redirect them to
different pages, using the Context.Server.Transfer(Target) method.

i.e :
Original ==> http://myserver/notExist/HelloThere
to
Target ==> http://myserver/DoesExist/helloWorld.aspx

the problem is that the DoesExist application receive the request and
it's web.config shows the following error:

Configuration error:
"Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS."

because notExist is not an appliaction in the web server, what should i
do to eliminate this problem?

Thanks!

Daberelay.

Nov 19 '05 #3
hey,
Thanks for the idea but Redirect causes a back and forth trip to the
client and also changes the url in the browser's address bar, what i
would like to do is cause the server to transfer without having to tell
the client about it.

any more ideas ?

Nov 19 '05 #4
Hey there,
Thanks for the lead but it is suggesting using a workarround for asp
instead of ihttpmodule, and moreover it offers using the redirect
function instead of the server.transfer function. it's of no use to me
as i would like to change the response output without going to the
client machine.

DaberElay.

Nov 19 '05 #5
<da*******@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
hey,
Thanks for the idea but Redirect causes a back and forth trip to the
client and also changes the url in the browser's address bar, what i
would like to do is cause the server to transfer without having to tell
the client about it.

any more ideas ?


One idea is that you _try_ redirect and see if it works. If it works, that
will tell you that the problem has to do with a difference between redirect
and Server.Transfer. If it doesn't work, that will tell you that the problem
has nothing to do with the difference between redirection and
Server.Transfer.

My concern is that there is nothing to transfer _from_ yet. In your code,
before your Server.Transfer, what kind of object is referenced by
Context.Handler?

John Saunders
Nov 19 '05 #6
<da*******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hey there,
Thanks for the lead but it is suggesting using a workarround for asp
instead of ihttpmodule, and moreover it offers using the redirect
function instead of the server.transfer function. it's of no use to me
as i would like to change the response output without going to the
client machine.


I was not offering it as a workaround. I was offering it as a diagnostic
technique.

John Saunders
Nov 19 '05 #7
Sorry John,
I think there was a confusion here, the workarround line i wrote was
reffering another answer i got from George a. beamer...

as per your answer, i know redirect works (and anyhows i did it again
just to verify), because redirect doesn't touch the source of the
problem. redirect asks the client's browser to change it's request and
send it again...
the transfer function trys to do it without ever leaving the server
side.

as for the Context.Handler, its <undefined value> ( i.e. null reference
), what can we understand from this ? is there something i need to
instanciate first ?
Your concern is correct, there is nothing to transfer from just yet,
simply because the original request was for a page that doesn't exist.
Thanks for the responsiveness!

DaberElay.

Nov 19 '05 #8
<da*******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Sorry John,
I think there was a confusion here, the workarround line i wrote was
reffering another answer i got from George a. beamer...

as per your answer, i know redirect works (and anyhows i did it again
just to verify), because redirect doesn't touch the source of the
problem. redirect asks the client's browser to change it's request and
send it again...
the transfer function trys to do it without ever leaving the server
side.

as for the Context.Handler, its <undefined value> ( i.e. null reference
), what can we understand from this ? is there something i need to
instanciate first ?
Your concern is correct, there is nothing to transfer from just yet,
simply because the original request was for a page that doesn't exist.
Thanks for the responsiveness!


I no longer recall the details of the original problem, but I know became
concerned because I suspected that Context.Handler would be null. I'm
frankly surprised that Server.Transfer works at all.

Have you looked into Url Rewriting using Context.RewritePath? I have used it
successfully in a similar situation.

John Saunders
Nov 19 '05 #9

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

Similar topics

5
by: Jon Sequeira | last post by:
Is there a way to redirect from an ASP.NET page to an ASP page without showing the ASP page's URL in the client's browser? This works perfectly with an HTML page, for example: path =...
2
by: ndario | last post by:
i am trying to transfer a user to another page with Server.Transfer() but i am having a problem with sending query params like this Server.Transfer("newPage.aspx?param=value"); in the PageLoad...
2
by: Kenneth Myhra | last post by:
Hi, We have been trying to develop an IHTTPModule (that was supposed to replace or take over the ISAPI Filters, as far as we know). We have developed one in C# and it seems to be working. The...
1
by: Victor Song | last post by:
Hi We are trying to stream a file using server.transfer rather than response.redirect. We have it working for IIS 5.0 but IIS 6.0 refusing to let us transfer the file. If we do the less...
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
5
by: Richard | last post by:
I've developed a small ASPX template framework (based on Chun Li's article on CodeProject: http://www.codeproject.com/aspnet/headerfooter.asp#xx849313xx) which uses a IHttpModule to apply...
3
by: Joseph S. | last post by:
Is there a system available to do the following: consider an app of a few pages: page1.php: form1----->page3.php form2----->page4.php page2.php: form3----->page3.php form4----->page4.php
1
by: omantawy | last post by:
Hi, I have some legacy ASP web applications that use an unmanaged COM component to connect to a third party application. The third part application has moved to the managed code in the current...
12
by: Mark Rae | last post by:
Hi, See the previous thread Request.Form abuse in this newsgroup... I'm looking for a simple and efficient way to prevent people hijacking the <formtags on my websites and using them to send...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.