GotKnowHow.com

How to Access GetRouteUrl in .ashx IHttpHandler's

by


ASP.NET Routing

For a while I wasn't sure how to access GetRouteUrl from an .ashx IHttpHandler page.   I wanted to access route url's setup in the Global.asax file to be used in files like rss.ashx,  instead of having to hard codes the page URL's in my .ashx pages.  Well, this routing problem isn't so difficult once you know how to do it.  To access and use GetRouteUrl in an .ashx follow this simple example:

string url = new System.Web.UI.Control().GetRouteUrl("ArticleStory", new { pathname = pathName });

It's as simple as that...!  You'll just need to change the routeName, and object parameters to your specific Route.

Also if you need to get fully qualified URL's see: How to Get Fully Qualified Route Urls from GetRouteUrl

 


0
0

Add your comment

by Anonymous - Already have an account? Login now!
Your Name:  

Comment:  
Enter the text you see in the image below
What do you see?
Can't read the image? View a new one.
Your comment will appear after being approved.


Did this article help you out, share it with your friends:

Ask a Question

140 characters left

Recent Articles