Take the 2-minute tour ×

Consider this scenario: You want to redirect (REDIRECT) a user to a certain handler (aspx or ashx) without hardcoded path. You have the name of the handler's class, you can even get it's type (ASP.whateverpageclass). Now, how do you get the virtual path?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

If I understood correctly, you want a virtual path for a handler if you have the name/type of implementing class. AFAIK, this is not possible because there need not be one to one correlation between two - from ASP.NET run-time perspective, it has to map a virtual path to some handler class (and not a vice-verse). For example, you can have all paths to certain extension be mapped with the same handler type.

As far as your main problem of avoiding hard-coding is concerned, you can handled that having configurable url (to redirect) or have persistent store (database, xml file or config file) that can map some key (for example, handler class name) to virtual path to redirect.

share|improve this answer
Seems like you can't be wrong, but mapping paths is just a pain. –  poopysprint Jun 7 '11 at 10:05
I guess defining static property with respective virtual location will work fo now. Thank you. –  poopysprint Jun 7 '11 at 10:10
add comment

Your Answer


