.net Rackspace云重写jpg导致会话重置

.net Rackspace云重写jpg导致会话重置,.net,url-rewriting,session-state,mosso,rackspace-cloud,.net,Url Rewriting,Session State,Mosso,Rackspace Cloud,这可能是的.NET版本 我有一个包含以下内容的图像脚本: ... Response.WriteFile(filename); Response.End(); 我正在使用web.config中的以下重写规则重写.jpg文件: <rule name="Image Redirect" stopProcessing="true"> <match url="^product-images/(.*).jpg" /> <conditions> <ad

这可能是的.NET版本

我有一个包含以下内容的图像脚本:

...
Response.WriteFile(filename);
Response.End();
我正在使用
web.config
中的以下重写规则重写.jpg文件:

<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>
我尝试将这些缓存禁用节点添加到web.config:

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



尝试使用httphandler,而不是使用URL重写。如果是重写导致了Rackspace Cloud上的问题,那么这应该可以解决问题,因为它消除了重写的使用:

在应用程序代码文件夹中创建httphandler类:

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
}
以及集成IIS模式:

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

最后一件事-您可能需要创建一个名为“product images”的物理文件夹,以便IIS在找不到该文件夹时不会返回404

另一件需要注意的事情是,这可能是完成所需操作的更好方法,因为HttpHandler不必经历正常的ASP.NET页面生命周期,这意味着在服务器上执行此操作需要更少的内存和时间


祝你好运,伙计

尝试使用httphandler,而不是使用URL重写。如果是重写导致了Rackspace Cloud上的问题,那么这应该可以解决问题,因为它消除了重写的使用:

在应用程序代码文件夹中创建httphandler类:

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
}
以及集成IIS模式:

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

最后一件事-您可能需要创建一个名为“product images”的物理文件夹,以便IIS在找不到该文件夹时不会返回404

另一件需要注意的事情是,这可能是完成所需操作的更好方法,因为HttpHandler不必经历正常的ASP.NET页面生命周期,这意味着在服务器上执行此操作需要更少的内存和时间


祝你好运,伙计

事实证明,这是Rackspace无法修复的限制

为了解决这个问题,我不得不使用不同的子域来托管图像(images.site.com)。 子域只是主站点的别名,但主机名阻止会话在www.site.com上重置

我添加了一些重写,指向我处理Web.Config图像检索的脚本,以保持图像从该子域返回,并在用户直接浏览该子域时重定向回

另外,我怀疑雷夫下面的回答也能解决这个问题。
如果你遇到这个问题,那就是你应该追求的解决方案

事实证明,这是Rackspace无法修复的限制

为了解决这个问题,我不得不使用不同的子域来托管图像(images.site.com)。 子域只是主站点的别名,但主机名阻止会话在www.site.com上重置

我添加了一些重写,指向我处理Web.Config图像检索的脚本,以保持图像从该子域返回,并在用户直接浏览该子域时重定向回

另外,我怀疑雷夫下面的回答也能解决这个问题。
如果你遇到这个问题,那就是你应该追求的解决方案

我有一个解决方法,它只使用“images.domain.com”来显示图像-如果会话在该图像上丢失,就这样做。域它不会损害主站点。我有一个解决方法,只使用“images.domain.com”来显示图像-如果会话在该图像上丢失,就这样。域它不会伤害主站点。+1这是迄今为止最好的答案-如此好,它让其他站点消失了!但是我不能接受,因为按钮不在那里。也许这是赏金的一部分?是的,也许赏金在这么多小时后就消失了。不用担心。+1这是目前为止最好的答案-太好了,其他人都消失了!但是我不能接受,因为按钮不在那里。也许这是赏金的一部分?是的,也许赏金在这么多小时后就消失了。别担心。
<handlers>
    <add name="ProductImageHandler" preCondition="integratedMode" verb="*" path="*/product-images/*.jpg" type="ProductImageHandler"/>
</handlers>