Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 806553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:15:39+00:00 2026-05-15T00:15:39+00:00

This may be the .NET version of this question . I have an image

  • 0

This may be the .NET version of this question.

I have an image script with the following:

...
Response.WriteFile(filename);
Response.End();

I am rewriting .jpg files using the following rewrite rule in web.config:

<rule name="Image Redirect" stopProcessing="true">
  <match url="^product-images/(.*).jpg" />
  <conditions>
    <add input="{REQUEST_URI}" pattern="\.(jp?g|JP?G)$" />
  </conditions>
  <action type="Rewrite" url="/product-images/ProductImage.aspx?path=product-images/{tolower:{R:1}}.jpg" />
</rule>

It basically just rewrites the image path into a query parameter.

The problem is that (intermittently of course) Mosso returns a new ASP Session cookie which breaks the whole world.

  • Directly accessing a static .jpg file does not cause this problem.
  • Directly accessing the image script does not cause it either.
  • Only rewriting a .jpg file to the .aspx script causes the session loss.

It’s not a redirect loop – the image appears, but the cache server submits a new session cookie, which (because it’s coming from my hostname) causes the session to reset.


Things I have tried

(From the Rackspace documentation How can I bypass the cache?)

I added Private cacheability to the image script itself:

Response.Cache.SetCacheability(HttpCacheability.Private);

I tried adding these cache-disabling nodes to web.config:

<staticContent>
  <clientCache cacheControlMode="DisableCache" />
</staticContent>

and

<httpProtocol>
  <customHeaders>
    <add name="Cache-Control private" value="Cache-Control private"
  </customHeaders>
</httpProtocol>

The Solution I need

The browser cache cannot be disabled. This means potential solutions involving Cache.SetNoStore() or HttpCacheability.NoCache will not work.

Alternately…

Please tell me why this is impossible to fix.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:15:39+00:00Added an answer on May 15, 2026 at 12:15 am

    Try using an httphandler instead of using URL rewrite. If it is the rewrite that is causing the problem on Rackspace Cloud, then this should fix the problem because it eliminates the use of rewrite:

    Create an httphandler class in your App_Code folder:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.IO;
    /// <summary>
    /// Summary description for ProductImageHandler
    /// </summary>
    public class ProductImageHandler : IHttpHandler
    {
        public ProductImageHandler()
        {
    
        }
    
        #region IHttpHandler Members
    
        public bool IsReusable
        {
            get { return true; }
        }
    
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "image/jpg";
    
            // get path to image
            string pathString = Path.GetFileNameWithoutExtension(context.Request.RawUrl);
    
            // open file
            // ... insert your logic for manipulating pathString
            // so that it points to file you want to output
            // maybe something like pathString = "~/images/" + pathString + ".jpg";
    
            context.Response.WriteFile(pathString);
        }
    
        #endregion
    }
    

    And then setup entries in your web.config file so that this handler gets sent requests for JPEG files in the “/product-images/” folder:

    <httpHandlers>
        <add verb="*" path="*/product-images/*.jpg" type="ProductImageHandler" validate="false"/>
    </httpHandlers>
    

    And also for integrated IIS mode:

    <handlers>
        <add name="ProductImageHandler" preCondition="integratedMode" verb="*" path="*/product-images/*.jpg" type="ProductImageHandler"/>
    </handlers>
    

    One last thing – you will probably have to create a physical folder called “product-images” so that IIS doesn’t return a 404 when it can’t find the folder.

    One other thing to note is that this is probably a better way to accomplish what you need to do because httphandlers don’t have to go through the normal ASP.NET page life-cycle, which means this requires less memory and time to execute on the server.

    Good luck dude!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to ASP.NET MVC so this may be a stupid question. I have
This may sound strange but sometimes when your ASP.NET webapp isn't working and you
I'm new to C# and .Net in general so this may be a naive
This may seem like a daft question, but i was wondering about how to
This may seem like a programming 101 question and I had thought I knew
This may be a doozy, but does anyone have an idea how to: Pass
This may be a no-brainer for the WPF cognoscenti, but I'd like to know
This may be simple one, but 5 mins of Googling didn't give me the
This may be a simple fix - but I'm trying to sum together all
This may be a matter of style, but there's a bit of a divide

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.