2012-12-13 10 views
5

Sitecore henüz MVC 4'ü desteklemiyor ve System.Web.Optimization'un paketlemesini ve minifikasyonunu kullanmak istiyorum.Sitecore 6.6, MVC 3 ve System.Web.Optimizasyon?

Paket istekleri 404 ile yanıt bulunamadı.

BundleConfig.cs:

public class BundleConfig 
{ 
    // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725 
    public static void RegisterBundles(BundleCollection bundles) 
    { 
     bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
        "~/Scripts/jquery-{version}.js")); 

     bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
        "~/Scripts/jquery-ui-{version}.js")); 

     bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
        "~/Scripts/jquery.unobtrusive*", 
        "~/Scripts/jquery.validate*")); 

     // Use the development version of Modernizr to develop with and learn from. Then, when you're 
     // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 
     bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
        "~/Scripts/modernizr-*")); 

     bundles.Add(new StyleBundle("~/content/css").Include(
        "~/Content/site.css", 
        "~/Content/960.gs/960.css")); 

     bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
        "~/Content/themes/base/jquery.ui.core.css", 
        "~/Content/themes/base/jquery.ui.resizable.css", 
        "~/Content/themes/base/jquery.ui.selectable.css", 
        "~/Content/themes/base/jquery.ui.accordion.css", 
        "~/Content/themes/base/jquery.ui.autocomplete.css", 
        "~/Content/themes/base/jquery.ui.button.css", 
        "~/Content/themes/base/jquery.ui.dialog.css", 
        "~/Content/themes/base/jquery.ui.slider.css", 
        "~/Content/themes/base/jquery.ui.tabs.css", 
        "~/Content/themes/base/jquery.ui.datepicker.css", 
        "~/Content/themes/base/jquery.ui.progressbar.css", 
        "~/Content/themes/base/jquery.ui.theme.css")); 
    } 
} 

_Layout.cshtml: demetleri

@using System.Web.Optimization 
<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <title>@ViewBag.Title</title> 
     @Styles.Render("~/Content/css") 
     @Scripts.Render("~/bundles/modernizr") 
    </head> 
    <body> 
     <div class="container_12"> 
      <a href="/"><h1>Title</h1></a> 
      @Html.Action("Utilities", "Navigation") 
      @Html.Action("Menu", "Navigation") 
      @RenderBody() 
     </div> 
     @Scripts.Render("~/bundles/jquery") 
     @RenderSection("scripts", required: false) 
    </body> 
</html> 

Yollar sanal ve fiziksel klasörlere eşleşmeyebileceğinden.

yok sayılması yolları bir NotImplementedException ve 500 iç sunucu hatası atar:

routes.IgnoreRoute("content/{*pathInfo}"); 
routes.IgnoreRoute("bundles/{*pathInfo}"); 

.. ama aksi istekler Sitecore tarafından ele ve bir 404 Not Found + Yönlendirme yanıt vardır.

Ben de denedim:

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="false"> 
     <remove name="BundleModule"/> 
     <add type="System.Web.Optimization.BundleModule" name="BundleModule"/> 
    </modules> 

Tüm bu alamayan birlikte çalışmaya çağırdı. Yardım et!

+0

Sitecore'un, paketler ele alınmadan önce tüm rotayı yakalayabileceğini düşünüyorum. – maxbeaudoin

cevap

9

ALLAH'ın annesi!

Hackaround aşağıdaki yolları:

routes.MapRoute(
    "sc_ignore_Bundles_Css", 
    "content/{*pathInfo}" 
); 

routes.MapRoute(
    "sc_ignore_Bundles_Js", 
    "bundles/{*pathInfo}" 
); 
+0

Bunun düzgün çalışması için başka bir şey yapmanız gerekiyor mu? Rotaları eklemeyi denedim, ancak sitecore paket veya içerik isteklerini ele geçirmeyi ve bir öğenin bulunamadı hatası döndürmeyi sürdürüyor. – Mike

+0

Bu projeyi elimde artık yok ama hatırlayabildiğim kadarıyla ... emin olmalısın (bazılarında.config dosyası) 'dışlama modeli' 'sc_ignore_' olarak ayarlanmış. – maxbeaudoin

+0

Web.config dosyasındaki ignoreurlprefix'lere/content/ve/bundle// ekledim. Ama sanki ona daha fazla eklemem gerektiğini söylüyorsun gibi mi geliyor? Sc_ignore için google'a gidip ne bulabileceğimi göreceğim. Teşekkürler! Bir yan not olarak. URL'leri ignoreurlprefix'e eklediğimde, staticfile işleyicisi devreye giriyor ve ben sadece düzenli bir 404 hatası alıyorum = \ – Mike

4

Örneğin bunu kullanmanızı sağlar "/ paketleri" dahil etmek için bu ayarı yama edebilirsiniz sayılabilir bir Sitecore yapılandırma kullanarak, "IgnoreUrlPrefixes" adlı bir Sitecore ayar yoktur ASP.NET Web Optimizasyonu paketleme özellikleri için/bundles/* urls. ,

<system.webServer> 
<modules runAllManagedModulesForAllRequests="false"> 
    <remove name="BundleModule"/> 
    <add type="System.Web.Optimization.BundleModule" name="BundleModule"/> 
</modules> 
... 

Second:

Öncelikle web.config için bu ekleyin: güncelleme 5 Sitecore 6.6 kullanarak Benim durumumda

+0

Sitecore 7.x'i kullanmak gerekli olan tek şey bu gibi görünüyor: |/paketler –

1

, ben aşağıdakileri yaparak çalışmaya donatılacak almak başardı I demet tabloda demetleri kayıt boru hattına bir boru hattı yöntemi eklendi:

[UsedImplicitly] 
public virtual void Process(PipelineArgs args) 
{ 
    BundleTable.EnableOptimizations = true;    
    RegisterBundles(BundleTable.Bundles); 
} 

private void RegisterBundles(BundleCollection bundles) 
{ 
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
       "~/Scripts/jquery-{version}.js")); 
} 

sonraki, bir yama dosyası ile boru hattına boru hattı yöntemi eklendi:

Bir şampiyon gibi çalıştı -
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> 
    <sitecore> 
     <pipelines> 
     <initialize> 
      <processor patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeGlobalFilters, Sitecore.Mvc']" 
       type="MyStuff.Web.Pipelines.RegisterMyBundles, MyStuff.Web" /> 
     </initialize> 
     </pipelines> 
    </sitecore> 
</configuration> 

Son olarak, eklemem/Sitecore ayarını IgnoreUrlPrefixes yamalı başka ihtiyaç vardı Hiç ... yol

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> 
    <sitecore> 
     <settings> 
     <setting name="IgnoreUrlPrefixes" 
        value="(all other sitecore paths here)|/bundles"/> 
     </settings> 
    </sitecore> 
</configuration> 

demetleri.