title: How do I serve assembly embedded resources from MVC 3 and IIS7?
body: <p>I'm developing an MVC 3 application with a "plugin" functionality.  The
  plugins are C# dll's with all required resources (css, images and scripts) embedded.</p>
  
  <p>I've used the "MvcRazorClassGenerator" Visual Studio extension to create precompiled views.</p>
  
  <p>I retrieve the embedded resource using the following code:</p>
  
  <pre><code>public FileStreamResult EmbeddedResource(string pluginName, string resourceName)
  {
    Assembly assembly = PluginCache.GetAssembly(pluginName);
  
    if (assembly != null)
    {
      string tempResourceName =
        assembly.GetManifestResourceNames()
                .ToList().FirstOrDefault(f =&gt; f.EndsWith(resourceName));
  
      return new FileStreamResult(
                    assembly.GetManifestResourceStream(tempResourceName), 
                    GetMIMEType(tempResourceName));
    }  
  
    return null;
  }
  </code></pre>
  
  <p>In the views I have following code to access resources:</p>
  
  <pre><code>@Url.Content("/Common/EmbeddedResource/PluginName/[AssemblyNamespace].Content.Images.blank.gif")
  </code></pre>
  
  <p>All is working fine while I am in the development environment, all resources are loaded and displayed correctly, but when deploying, the nightmare is started.</p>
  
  <p>IIS 7.5 keeps searching for a static file called "/Common/EmbeddedResource/PluginName/[AssemblyNamespace].Content.Images.blank.gif" and not the embedded file, giving me the 404 error for all embedded resources.</p>
  
  <p>I've tried installing a hot fix mentioned by a question on this site and changing config files but the resources are not loaded.</p>
  
  <p>I'm trying to deploy to Windows 2008 Server R2 SP1 64bit.</p>