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

How to trick a page into running at a location different from it'sphysical location?

I have an application with a web page that I would like to run as if it
were at a different location than it actually resides at. As an example:

Imagine that I have a site layout as,

~/
~/foo/
~/foo/bar/

Web.config files exist at

~/web.config
~/foo/web.config
~/foo/bar/web.config

I have a web page

~/default.aspx

If someone comes along an requests page

~/foo/bar/default.aspx

I would like the request to be handled by ~/default.aspx, but as if it
were located at ~/foo/bar/default.aspx, importantly, I want all of the
inherited web.config information to reflect the ~/foo/bar/ path
hierarchy. I also want page-relative links to resolve based at ~/foo/bar.

I can't rewrite the path via RewritePath because the framework executes
~/default.aspx as if it is at ~/default.aspx, and I can't redirect the
client or server.transfer for the same reason.

I have written a custom IHttpHandlerFactory that handles determining the
correct page to load for each request (not precisely url rewriting but
similar), but I can't figure out how to get the page to load as if it is
at the requested url.

Essentially, my factory looks like this:

string newPath = DetermineNewPathForRequest(context);
return PageParser.GetCompiledPageInstance(newPath,
HostingEnvironment.MapPath(newPath), context);

This almost works. Page relative links resolve correctly, and custom
configuration sections that I've written respond to
WebConfigurationManager.GetSection calls correctly, but built-on
configuration sections don't get the inherited data.

For instance, if I define

~/web.config <- <pages masterPageFile="default" theme="default" />
~/foo/web.config <- <pages masterPageFile="foo" theme="foo" />
~/foo/bar/web.config <- <pages masterPageFile="bar" theme="bar" />

requesting ~/default.aspx, ~/foo/default.aspx, or ~/foo/bar/default.aspx
always returns a page with the default theme and master file, rather
than default.aspx customized with the appropriate theme/master set by
the execution directory's web.config, even though my factory doesn't
redirect, just loads the page directly.

This disparity between the automatic configuration sections and the
custom sections returned from WebConfigurationManager.GetSection really
confuses me. Does anyone know if I'm running into a bug, or is there
something about PageParser.GetCompiledPageInstance that I don't understand.

Thanks in advance, and sorry for the long post,
Luke
Jan 15 '06 #1
0 1087

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

Similar topics

5
by: TG | last post by:
Dear PHP Group, How can I in PHP, based on a result, move the cursor to a certain location on the page? I want the same result as Anchor tags in HTML. I want to go to a certain section of the...
2
by: Joseph Oget | last post by:
hi guys, how do I retrive the actual location of a page, I want to do s script that will open a window prefixing the document path to a local folder. TIA Joseph
1
by: | last post by:
Hello, I have a problem when I try to do this on a aspx page.. Is there anything wrong with this approach? This is the javascript function <Script Language='JavaScript'> function...
10
by: Eric Lindsay | last post by:
This may be too far off topic, however I was looking at this page http://www.hixie.ch/advocacy/xhtml about XHTML problems by Ian Hickson. It is served as text/plain, according to Firefox...
0
by: Gentian Hila | last post by:
I have a crystal report that is being displayed on the web (asp.net – VS studio 2003). I use a wait page, a very simple one, to tell the user to wait until the report is displayed, simply...
6
by: Mat N | last post by:
Hello access friends, (Originally posted on access.formsprogramming which I think was the wrong place) I'm precalculating a bunch of data for my clients as per a profile I have for each of...
6
by: mcnews | last post by:
How can I direct Response.Write to output to a specific location on my page? TIA, mcnewsxp
0
by: coopdog | last post by:
This is a new issue as of an install to sp1 on vb express 2005. When I publish the application to my drive then I try to install it is wants to be installed from the same location as it was...
8
by: sake | last post by:
I have a script running in a frame. This script needs to be able to redirect the browser to an entirely different location. However, with the header("location: ") method, only that frame's source is...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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
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,...

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.