Last post Oct 25, 2010 06:22 AM by CeOfFuture
Oct 24, 2010 05:58 PM|CeOfFuture|LINK
Hello. what i want is pretty easy .
my all image paths are relative atm. so they are getting processed like this
what i want is to convert all image paths to this with image http handler
static.pokemoncraft.com domain is cookieless
so this will reduce http headers size and increase performance
i think this should be pretty easy
Oct 25, 2010 03:16 AM|Hubble|LINK
You don't really want an httpHandler but an httpModule instead.
Have a look here:
You could also override the Render method of your Page class and replace one domain by another, like the following snippet:
protected override void Render(HtmlTextWriter writer)
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
string html = htmlwriter.InnerWriter.ToString();
html = html.Replace("www.pokemoncraft.com/images/","static.pokemoncraft.com/images/");
Hope this helps
Oct 25, 2010 04:35 AM|CeOfFuture|LINK
read below post
Oct 25, 2010 05:15 AM|CeOfFuture|LINK
ok i have come to this far
i think you can help me from here :)
Oct 25, 2010 06:04 AM|Hubble|LINK
The left alignment of your body has nothing to do with the code above, check your CSS to find the problem. Maybe you're writing something before de DOCTYPE definition and that's causing the page not to render ok. Check the source code generated in the browser.
The best solution I found was to create a class that inherits from System.Web.UI.Page and then inherit all the pages in your project from that base class.
This solution is working for me doing three complex replacements with regular expressions serving up to 2.000.000 pages per month and the processor is not suffering very much.
Hope this helps.
Oct 25, 2010 06:10 AM|Hubble|LINK
This is wrong, you use RewritePath to rewrite URLs, like the mod_rewrite does in Apache servers, nothing related to your code.
Check this blog, is really great to learn what you want to achieve:
Hope this helps
Oct 25, 2010 06:22 AM|CeOfFuture|LINK
ok it seems like this has solved my problem
private void Application_BeginRequest(Object source, EventArgs e)
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
string srFilePath = context.Request.FilePath;
string fileExtension =
srFilePath ="http://static.pokemoncraft.com/"+ srFilePath.Substring(srFilePath.IndexOf("images/"));
if (srFilePath.IndexOf("main_menu_") != -1)
srFilePath = "http://static.pokemoncraft.com/images/" + srFilePath.Substring(srFilePath.IndexOf("main_menu_"));
but processing every request to the http module would cost extra cpu
are there any way to make it process only png jpg and gif files ?
like at web config file ?
edit: tried this and this does completey different thing :(