小编Shi*_*abh的帖子

Chrome丢失了Cookie

我在我的实时网站上收到一个错误,我在Dev环境中没有看到这个错误,而且似乎只发生在Chrome上.我已经四处寻找解决方案,我发现只有Auth cookie的问题.(我实际上在过去提出了关于chrome和auth cookie的问题),但这是不同的.

我将用户购物车存放在cookie中.我这样设置了cookie

HttpCookie responseCookie = HttpContext.Response.Cookies[CartHelper.CART];
responseCookie.PackCartCookie(vm.Cart);
Run Code Online (Sandbox Code Playgroud)

扩展方法PackCartCookie设置cookie值的方式如此

cookie.Value = HttpUtility.UrlEncode(cookieValue);
Run Code Online (Sandbox Code Playgroud)

此结果是使用以下设置存储的cookie

  • Domain = www.foo.com
  • RawSize = 230b
  • 路径= /
  • Expires =会话
  • HttpOnly = HttpOnly
  • 值=加密

当用户与网站进行交互时,似乎正在创建购物车Cookie,但它会不时丢失或丢失.当我查看Elmah错误并查看HTTP_COOKIE时,我可以看到所有其他cookie(我有其他设置方式相同,功能正常)但我没有看到购物车cookie.

由于这个问题,我不得不更改代码以更加防御.但是你可以想象购物车cookie在整个购买过程中被使用,而我在接受付款的时候我已经失败,但是当购物车消失并且没有通知用户成功购买时系统崩溃.幸运的是,我很早就抓住了这个并且退款的用户受到了影响.

我见过这个问题的用户代理

  • Mozilla/5.0(X11; Linux i686)AppleWebKit/537.36(KHTML,与Gecko一样)Chrome/29.0.1547.62 Safari/537.36
  • Mozilla/5.0(Windows NT 6.1; WOW64)AppleWebKit/537.36(KHTML,像Gecko)Chrome/29.0.1547.57 Safari/537.36
  • Mozilla/5.0(Windows NT 6.0)AppleWebKit/537.36(KHTML,像Gecko)Chrome/29.0.1547.62 Safari/537.36

cookies asp.net-mvc google-chrome

5
推荐指数
1
解决办法
3051
查看次数

用razor引擎在mvc4中重写url

我想重写以下网址 -

http://localhost:99/Product/CategoryLevel?CategoryId=65&ProductName=Vitamins

http://localhost:99/Product/Vitamins,

(要么)

http://localhost:99/Product/CategoryLevel/Vitamins

(要么)

http://localhost:99/Vitamins

(或)如何从URL中删除(或)隐藏查询字符串(显示给用户)?

我尝试使用url重写模块(iis)和asp.net路由并在互联网上搜索解决方案,但我没有找到正确的解决方案,请建议任何解决方案.

asp.net-mvc url-rewriting query-string asp.net-mvc-4 url-rewrite-module

4
推荐指数
1
解决办法
1万
查看次数

无法将类型'ListName []'隐式转换为'System.Collections.Generic.IList <ListName>'

我有一个具有某些属性的IList.我从数据库访问一组值返回IList的代码.我使用了一个webservice,它将完整的细节提供给列表.作为WCF的服务在WCFTestClient.exe中很好地执行.但是在代码隐藏中,放置时会显示错误.

public IList<BrandInfo> SearchProduct(string name)
{
    AuthenicationServiceClient obj = new AuthenicationServiceClient();
    return obj.SearchProducts(name); 

}
Run Code Online (Sandbox Code Playgroud)

它显示错误" Cannot implicitly convert type 'Model.BrandInfo[]' to 'System.Collections.Generic.IList<Models.BrandInfo>'"

Web服务中的代码是.

public IList<BrandInfo> GetBrandByQuery(string query)
{
    List<BrandInfo> brands = Select.AllColumnsFrom<Brand>()
        .InnerJoin(Product.BrandIdColumn, Brand.BrandIdColumn)
        .InnerJoin(Category.CategoryIdColumn, Product.CategoryIdColumn)
        .InnerJoin(ProductPrice.ProductIdColumn, Product.ProductIdColumn)
        .Where(Product.EnabledColumn).IsEqualTo(true)
        .And(ProductPrice.PriceColumn).IsGreaterThan(0)
        .AndExpression(Product.Columns.Name).Like("%" + query + "%")
        .Or(Product.DescriptionColumn).Like("%" + query + "%")
        .Or(Category.CategoryNameColumn).Like("%" + query + "%")
        .OrderAsc(Brand.NameColumn.ColumnName)
        .Distinct()
        .ExecuteTypedList<BrandInfo>();

    // Feed other info here
    // ====================
    brands.ForEach(delegate(BrandInfo brand)
    {
        brand.Delivery = GetDelivery(brand.DeliveryId);
    });

    return brands;
}
Run Code Online (Sandbox Code Playgroud)

如何从客户端访问此代码.我无法提取任何相关的在线参考.

c# asp.net wcf

3
推荐指数
1
解决办法
3621
查看次数