none
using css js optimization in sharepoint 2013 results with error on SPRequestModule.IsExcludedPath RRS feed

  • דיון כללי

  • I'm trying to use [built-in dot.net 4.5 feature web optimization][1] (css and js minification) on sharepoint 2013 website and i'm haveing an exception on ~ urls:

    > Exception Details: System.ArgumentException: virtualPath


    > Source Error:  An unhandled exception was generated during the
    > execution of the current web request. Information regarding the origin
    > and location of the exception can be identified using the exception
    > stack trace below. 

    > Stack Trace: 


    > [ArgumentException: virtualPath]   
    > Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.IsExcludedPath(String
    > virtualPath) +278   
    > Microsoft.SharePoint.ApplicationRuntime.SPVirtualPathProvider.DirectoryExists(String
    > virtualPath) +57   
    > System.Web.Optimization.BundleHandler.RemapHandlerForBundleRequests(HttpApplication
    > app) +136   
    > System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    > +182    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

    > Version Information: Microsoft .NET Framework Version:4.0.30319;
    > ASP.NET Version:4.0.30319.18408

    **Any idea how to solve this?**

    ***!!! UPDATED ON 12-03-2014!!!***

    **First problem solved! now we get error 404.0 from server upon performing GET action to the bundle.**

    Here's the code for skipping SharePoint virtual path validation mechanism:

    **ApplicationStartModule.cs**

        using System;
        using System.Collections.Generic;
        using System.Diagnostics;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Web;
        
        namespace Matrix.SharePoint.Publishing.HttpModules
        {
            public abstract class ApplicationStartModule : IHttpModule
            {
                private readonly static object _mutex = new object();
                private static bool _initialized = false;
        
                protected abstract void OnStart();
        
                public void Init(HttpApplication application)
                {
                    if (!_initialized)
                        lock (_mutex)
                            if (!_initialized)
                                Application_Start();
                }
        
                private void Application_Start()
                {
                    _initialized = true;
                    OnStart();
                }
        
                public void Dispose() { } 
            }
        }


    **RootVirtualPathProvider.cs**

        using Microsoft.SharePoint.ApplicationRuntime;
        using System;
        using System.Collections.Generic;
        using System.Diagnostics;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Web.Hosting;
        
        namespace Matrix.SharePoint.Providers
        {
            public class RootVirtualPathProvider : VirtualPathProvider
            {
                public override string CombineVirtualPaths(string basePath, string relativePath)
                {
                    return Previous.CombineVirtualPaths(basePath, relativePath);
                }
        
                public override System.Runtime.Remoting.ObjRef CreateObjRef(Type requestedType)
                {
                    return Previous.CreateObjRef(requestedType);
                }
        
                public override bool FileExists(string virtualPath)
                {
                    string patchedVirtualPath = virtualPath;
        
                    if (virtualPath.StartsWith("~/layouts", StringComparison.InvariantCultureIgnoreCase))
                    {
                        patchedVirtualPath = virtualPath.Remove(0, 1);
                    }
        
                    return Previous.FileExists(patchedVirtualPath);
                }
        
                public override System.Web.Caching.CacheDependency GetCacheDependency(string virtualPath, System.Collections.IEnumerable virtualPathDependencies, DateTime utcStart)
                {
                    return Previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);
                }
        
                public override string GetCacheKey(string virtualPath)
                {
                    return Previous.GetCacheKey(virtualPath);
                }
        
                public override VirtualDirectory GetDirectory(string virtualDir)
                {
                   return Previous.GetDirectory(virtualDir);
                }
        
                public override VirtualFile GetFile(string virtualPath)
                {
                    return Previous.GetFile(virtualPath);
                }
        
                public override string GetFileHash(string virtualPath, System.Collections.IEnumerable virtualPathDependencies)
                {
                    return Previous.GetFileHash(virtualPath, virtualPathDependencies);
                }
        
                protected override void Initialize()
                {
                    base.Initialize();
                }
            }
        }
         



    is there best practice how to use built-in dot net 4.5 web optimization in sp2013?

    thanks,
    guy bertental




      [1]: http://weblogs.asp.net/scottgu/archive/2011/11/27/new-bundling-and-minification-support-asp-net-4-5-series.aspx



    • שינה את הסוג Eran Sharvit יום רביעי 19 מרץ 2014 15:03
    • נערך על-ידי Guy bertental יום חמישי 20 מרץ 2014 07:16
    יום שני 17 מרץ 2014 11:09

כל התגובות

  • הי.

    לא מקובל להוסיף לינק לפורום אחר שבו נמצאת השאלה ולצפות שמומחי הקהילה או מנהל הפורום שפעיל כאן, יכתוב לך תשובה בפלטפורמה אחרת.

    המינימום הנדרש הוא לכתוב כאן מחדש את השאלה.

    תודה.


    מיקרוסופט מציעה שירות זה ללא תשלום, למטרת סיוע למשתמשים והעשרת הידע הקשור בטכנולוגיות ובמוצרים של מיקרוסופט. תוכן זה מתפרסם כפי שהוא והוא אינו מעיד על כל אחריות מצד מיקרוסופט.

    יום רביעי 19 מרץ 2014 15:07
  • בוצע
    יום חמישי 20 מרץ 2014 07:17