Last post Aug 27, 2009 08:30 AM by dotnetguts
Jan 13, 2009 04:48 AM|saeed_sp|LINK
Hi all. I have a simple urlrewriter.
I want to rewrite some path such as mysite/Sale to a special page with parameter like mysite/Find.aspx?y=sale.
But when I rewrite HttpCuntex.Request to page find.aspx it raise an error:
Server Error in '/mysite' Application.--------------------------------------------------------------------------------The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /mySite/Sale/find.aspx
Jan 18, 2009 10:27 PM|Nai-Dong Jin - MSFT|LINK
You need to focus on the following properties, try to get the application path (begin from the first letter to the first '/' char), and then add your specific page.
Jan 20, 2009 03:43 AM|saeed_sp|LINK
Hi.Thanks for replay. But I dont understand your mean.
Can you explain it ?
Jan 22, 2009 09:22 AM|bgs264|LINK
Are you hoping to use URL Rewriting to handle your 404 errors?
For example, you want an unfound page to be handled by a search engine?
You don't need URL Rewriting to do that, nor is it the best way. Instead, just use the customErrors section of web.config and provide a page to hande 404's. The asp.net engine will automatically then send any 404 errors to your new page with a query string
detailing the path the user tried to access. You can access that querystring and pass it to your search engine.
Jan 22, 2009 09:23 AM|bgs264|LINK
(If the above doesn't work, try rewriting to ~/find.aspx instead of just find.aspx)
Jan 24, 2009 02:27 AM|saeed_sp|LINK
I try it.
Jan 25, 2009 07:44 AM|saeed_sp|LINK
No I Dont want to handle page not found error.
Jan 25, 2009 04:34 PM|bgs264|LINK
Jan 26, 2009 02:13 AM|saeed_sp|LINK
Thanks ! .It works!.
But there is a problem.Now my images and css not appear !!!?
My page is fully NAKED !!!!!!???
Jan 26, 2009 09:41 AM|bgs264|LINK
When you rewrite the URL, in Context.RewritePath() method, it takes a name - and an overloaded method takes a boolean value.
I can't remember which but try
Context.RewritePath("~/find.aspx", True) and same with False.
See if that helps...
It's something to do with the path to the CSS file being incorrect (view the source in your browser and you'll see the problem)
Aug 27, 2009 08:30 AM|dotnetguts|LINK
Check out this article for understanding how to rewrite url using url rewiter