Note that there are some explanatory texts on larger screens.

plurals
  1. POVirtualPathProvider doesn't (quite) work in production on IIS 7.5
    primarykey
    data
    text
    <p>I have been working on a project that has common bits of functionality, specifically I wanted to share the master file and related images/js/etc. To that end, the master page and its dependent files are all wrapped into a "global" DLL that is utilized by all "subprojects". This all worked great in development, but deployment yielded a surprise which seems to catch a lot of people off guard: <code>VirtualPathProvider</code> doesn't work when precompiled. </p> <p>Now thanks to <a href="http://sunali.com/2008/01/09/virtualpathprovider-in-precompiled-web-sites/" rel="nofollow">this blog post containing a workaround</a> I was able to give another attempt at getting it to work. Regretfully, it still doesn't.</p> <p>I opted to get rid of my <code>Global.asax</code> implementation and went with the blog post's <code>AppInitialize</code> approach:</p> <pre><code>public static class AppStart { public static void AppInitialize() { HostingEnvironment hostingEnvironmentInstance = (HostingEnvironment)typeof(HostingEnvironment).InvokeMember("_theHostingEnvironment", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null); MethodInfo mi = typeof(HostingEnvironment).GetMethod("RegisterVirtualPathProviderInternal", BindingFlags.NonPublic | BindingFlags.Static); mi.Invoke(hostingEnvironmentInstance, new object[] { new MasterPageProvider() }); } } </code></pre> <p>Since the actual provider works in debug, I won't include it. If you would like to see it, don't hesitate to ask. Just wanted to keep the question as short as possible.</p> <p>The interesting aspect to this whole situation is that production yields no errors about not being able to find the master page. To me, this means the provider <em>is</em> working, but for whatever reason the rest of the resources (js/css/etc) aren't being retrieved from the assembly properly.</p> <p>So my question comes down to this: what are the reasons that this solution would work great in development, but not in production on IIS 7.5?</p> <hr> <p><strong>UPDATE 11/20/2011</strong></p> <p>Tried out David Ebbo's suggestion and had no results unfortunately. My web config looks something like this now:</p> <pre><code>&lt;configuration&gt; &lt;connectionStrings&gt; &lt;clear /&gt; &lt;!-- ... --&gt; &lt;/connectionStrings&gt; &lt;system.web&gt; &lt;pages&gt; &lt;controls&gt; &lt;!-- ... --&gt; &lt;/controls&gt; &lt;/pages&gt; &lt;compilation debug="true" targetFramework="4.0" /&gt; &lt;webServices&gt; &lt;protocols&gt; &lt;add name="HttpGet"/&gt; &lt;add name="HttpPost"/&gt; &lt;/protocols&gt; &lt;/webServices&gt; &lt;/system.web&gt; &lt;system.webServer&gt; &lt;modules runAllManagedModulesForAllRequests="true" /&gt; &lt;/system.webServer&gt; &lt;/configuration&gt; </code></pre> <hr> <p><strong>UPDATE 11/21/2011</strong></p> <p>Just to verify my suspicion that the VirtualPathProvider was actually working, I commented out the third line (<code>mi.Invoke(....</code>) and redeployed the site. As I suspected, it now breaks due to not being able to find the MasterPage file. This issue appears to be related to only static files being delivered through the VPP.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload