PC Review


Reply
Thread Tools Rate Thread

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

 
 
Luke Dalessandro
Guest
Posts: n/a
 
      15th Jan 2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Different Ststem Restore problem. Need to force/trick SR. HELP! Bubba Gump Windows XP Help 9 16th May 2005 11:36 AM
Trick the registry into thinking I've logged out. =?Utf-8?B?UGF1bA==?= Windows XP Security 3 8th Oct 2004 02:41 AM
Another avoid the loop trick request - on fast fill (Maybe an Alan trick) marston.gould@alaskaair.com Microsoft Excel Programming 2 6th Oct 2004 07:13 PM
How to add combo box into toolbar? any trick? Mat Microsoft VB .NET 2 15th Jul 2004 06:44 PM
Location, Location, Location... dev Windows XP General 5 18th Nov 2003 07:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:56 AM.