小编M. *_*ara的帖子

MVC4 StyleBundle不会以正确的顺序呈现包

我正在尝试渲染一组css文件,但输出顺序错误.我已经尝试过解决方案@ MVC4 Beta Minification and Bundling:在浏览器中订购文件和调试,但它没有帮助.这是捆绑:

bundles.Add(new StyleBundle("~/stylesheet")
    .Include("~/css/main.css")
    .Include("~/css/mvc.css")
    .Include("~/js/jquery.thickbox.css")
    .Include("~/js/jquery.rating.css")
    .Include("~/css/ProductListing.css")
    .Include("~/css/dropdown/dropdown.css")
    .Include("~/css/dropdown/dropdown.vertical.css")
    .Include("~/js/fancybox/jquery.fancybox-1.3.1.css")
    .Include("~/css/scartpopup.css")
    .Include("~/css/ShoppingCart.css")
    .Include("~/css/ceebox.css")
    .Include("~/css/tooltip.css")
    .Include("~/css/recent_blog_posts.css")
    .Include("~/css/ProductDetail.css")
    .Include("~/css/jquery-ui-1.7.3.custom.css")
    .Include("~/css/filter_box.css")
    .Include("~/css/custom_page.css")
    .Include("~/css/Checkout.css")
    .Include("~/css/CheckoutButton.css")
);
Run Code Online (Sandbox Code Playgroud)

这是结果,你可以看到jquery-ui到顶部.

<link href="/css/jquery-ui-1.7.3.custom.css" rel="stylesheet"/>
<link href="/css/main.css" rel="stylesheet"/>
<link href="/css/mvc.css" rel="stylesheet"/>
<link href="/js/jquery.thickbox.css" rel="stylesheet"/>
<link href="/js/jquery.rating.css" rel="stylesheet"/>
<link href="/css/ProductListing.css" rel="stylesheet"/>
<link href="/css/dropdown/dropdown.css" rel="stylesheet"/>
<link href="/css/dropdown/dropdown.vertical.css" rel="stylesheet"/>
<link href="/js/fancybox/jquery.fancybox-1.3.1.css" rel="stylesheet"/>
<link href="/css/scartpopup.css" rel="stylesheet"/>
<link href="/css/ShoppingCart.css" rel="stylesheet"/>
<link href="/css/ceebox.css" rel="stylesheet"/>
<link href="/css/tooltip.css" rel="stylesheet"/>
<link href="/css/recent_blog_posts.css" rel="stylesheet"/>
<link href="/css/ProductDetail.css" rel="stylesheet"/>
<link href="/css/filter_box.css" rel="stylesheet"/>
<link href="/css/custom_page.css" …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc-4 asp.net-optimization

15
推荐指数
1
解决办法
5873
查看次数

响应:413 请求实体太大

当发布一个可以包含一个或多个文件(作为 base64 字符串)的请求时,我收到以下错误响应:

错误 2018-11-22 09:54:18,244 [13] Mvc.ExceptionHandling.AbpExceptionFilter - 远程服务器返回意外响应:(413)请求实体太大。System.ServiceModel.ProtocolException:远程服务器返回意外响应:(413) 请求实体太大。在 System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) 在 System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) 在 System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult 结果)在 System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.b__0(IAsyncResult asyncResult) --- 从上一个抛出异常的位置开始的堆栈跟踪结束 --- 在 ...

我已经搜索了如何解决这个问题,但我一直被重定向到 WCF 解决方案。

我已将以下内容添加到我的 WebApi 项目的 web.config 中,但它似乎没有什么区别。

<configuration>
  <system.webServer>
    ....
    <asp>
      <limits maxRequestEntityAllowed="2147483648"/>
    </asp>
    <serverRuntime uploadReadAheadSize="2147483647" />
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我或为我指出正确的资源吗?

c# asp.net-core aspnetboilerplate asp.net-core-webapi

12
推荐指数
2
解决办法
2万
查看次数

为特定控制器操作选择自定义输出缓存提供程

我正在尝试实现MongoDB/Memory组合输出缓存提供程序以与MVC4一起使用.这是我最初的实现:

public class CustomOutputCacheProvider : OutputCacheProvider
{
    public override object Get(string key)
    {
        FileLogger.Log(key);
        return null;
    }

    public override object Add(string key, object entry, DateTime utcExpiry)
    {
        return entry;
    }

    public override void Set(string key, object entry, DateTime utcExpiry)
    {
    }

    public override void Remove(string key)
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

我的网络配置条目:

<caching>
  <outputCache defaultProvider="CustomOutputCacheProvider">
    <providers>
      <add name="CustomOutputCacheProvider" type="MyApp.Base.Mvc.CustomOutputCacheProvider" />
    </providers>
  </outputCache>
</caching>
Run Code Online (Sandbox Code Playgroud)

以及HomeController中的用法:

[OutputCache(Duration = 15)]
public ActionResult Index()
{
    return Content("Home Page");
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,当我检查日志文件中所请求的密钥时,我不仅看到了对主控制器的请求,还看到了所有其他路径:

a2/  <-- should only log this …
Run Code Online (Sandbox Code Playgroud)

c# asp.net caching asp.net-mvc-4

8
推荐指数
1
解决办法
2883
查看次数

搜索范围列表中数字的最快方法

我有以下代码来查找范围列表中的数字匹配.

public class RangeGroup
{
    public uint RangeGroupId { get; set; }
    public uint Low { get; set; }
    public uint High { get; set; }
    // More properties related with the range here
}

public class RangeGroupFinder
{
    private static readonly List<RangeGroup> RangeGroups=new List<RangeGroup>();

    static RangeGroupFinder()
    {
        // Populating the list items here
        RangeGroups.Add(new RangeGroup { RangeGroupId = 0, Low = 1023238144, High = 1023246335 });
        RangeGroups.Add(new RangeGroup { RangeGroupId = 0, Low = 1023246336, High = 1023279103 }); …
Run Code Online (Sandbox Code Playgroud)

c# algorithm optimization performance c#-4.0

8
推荐指数
1
解决办法
3008
查看次数

如何获取列表框中的项目数

在我的程序中我拿了一个列表框,在这个列表框中我添加了一些项目.

现在我想知道如何获取列表框项目的数量并显示文本框中的项目数.当项目数量不固定时.

.net c# listbox

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

在此ConcurrentDictionary缓存方案中是否需要锁定

我有以下代码来缓存我在多线程应用程序中使用的并发字典中的某些类的实例.

简单地说,当我使用id参数对类进行即时化时,它首先检查字典中是否存在具有给定id的私有类的实例,如果没有,则创建私有类的实例(这需要很长时间,有时几秒),并将其添加到字典中以供将来使用.

public class SomeClass
{
    private static readonly ConcurrentDictionary<int, PrivateClass> SomeClasses =
        new ConcurrentDictionary<int, PrivateClass>();

    private readonly PrivateClass _privateClass;

    public SomeClass(int cachedInstanceId)
    {
        if (!SomeClasses.TryGetValue(cachedInstanceId, out _privateClass))
        {
            _privateClass = new PrivateClass(); // This takes long time
            SomeClasses.TryAdd(cachedInstanceId, _privateClass);
        }
    }

    public int SomeCalculationResult()
    {
        return _privateClass.CalculateSomething();
    }

    private class PrivateClass
    {
        internal PrivateClass()
        {
            // this takes long time
        }

        internal int CalculateSomething()
        {
            // Calculates and returns something
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,我是否需要在外部类构造函数的生成和赋值部分周围添加一个锁,以使此代码线程安全或者它是否很好?

更新:

在SLaks的建议之后,试图将ConcurrentDictionary的GetOrAdd() …

c# concurrency multithreading

3
推荐指数
2
解决办法
4559
查看次数

使用 C# mongo 驱动程序构建查询

我想知道如何使用 mongo 驱动程序构建复杂的查询。这是我的查询:

var builder = Builders<MongoNavFilter>.Filter;
var query = builder.Where(x => x.Link == link && x.SubLink == subLink);
if (some statement)
{
    var finalExpression = ...
    query = query & Builders<MongoNavFilter>.Filter.Where(finalExpression); 
}
if (onsale)
    query = query & Builders<MongoNavFilter>.Filter.Where(x => !(x.Promo == null && x.Promo == string.Empty));

var filters = _db.GetCollection<MongoNavFilter>("NavFilters").
                    Find(query).ToList();
Run Code Online (Sandbox Code Playgroud)

这段EF IQueryable代码工作正常,但我无法使用mongo driver. 谁能告诉我我做错了什么?

c# mongodb mongodb-.net-driver

0
推荐指数
1
解决办法
3495
查看次数