Getting URL for a Page

  • Thread starter Thread starter Kent Boogaart
  • Start date Start date
K

Kent Boogaart

Hi,

If I know a type which extends System.Web.UI.Page, is there any way I can
figure out what the URL for that page is? The closest I've come to this is
to:
1. Construct an instance of the type.
2. Use the AppRelativeVirtualPath property (new to 2.0 which I am using).

I have two problems with this approach. Firstly, I have to construct a page
instance and I was really hoping I wouldn't have to. Secondly, I haven't
looked deeply into the AppRelativeVirtualPath property yet so I'm not
entirely sure whether it is exactly what I want (but it seemed to work for
my simple test).

Thanks,
Kent
 
Request.Url

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.
 
No, I think you misunderstood my question.

I have a type that implements a page, nothing else. How do I determine the
URL that I can forward to that will execute that page? The best I can come
up with is:

Type pageType = typeof(SomePage);
Page page = (Page) Activator.CreateInstance(pageType);
string url = page.AppRelativeVirtualPath;
//now I can forward to url

But this requires I construct the page (which will be constructed again when
I forward to the URL). Is there any way to get that URL without constructing
the page, based only on the page type?

Thanks,
Kent
 
I'm lost, man. Assuming that you have a page somewhere, you ought to know
the location of it, right?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.
 
Sorry, probably not explaining myself properly.

A config file specifies a type which implements a page (it does not specify
the URL for the page). I need to forward to a URL so that the page will be
run by the ASP.NET runtime. Hopefully that makes sense...

Regards,
Kent
 
Sounds like you need to write an HttpHandler class and implement that in
your app.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Complex things are made up of
Lots of simple things.
 
There is no way to determine the URL from the type, or the page object. That
can only be determined by querying the web server. XCOPY deployment means
that your page and dll can be copied ANYWHERE. At that point everything is
relative.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top