Using CSS and JavaScript optimization in SharePoint 2013 results with error on SPRequestModule.IsExcludedPath -
i'm trying use built-in dot.net 4.5 feature web optimization (css , javascript minification) on sharepoint 2013 website , i'm having exception on ~ urls:
exception details: system.argumentexception: virtualpath
source error: unhandled exception generated during execution of current web request. information regarding origin , location of exception can identified using 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) +165version information: microsoft .net framework version:4.0.30319; asp.net version:4.0.30319.18408
any idea how solve this?
!!! updated on 12-03-2014!!!
first problem solved! error 404.0 server upon performing action bundle.
here's code 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 use built-in .net 4.5 web optimization in sharepoint 2013?
Comments
Post a Comment