Kahia.EmbeddedResourceVirtualPathProvider 1.1.0

dotnet add package Kahia.EmbeddedResourceVirtualPathProvider --version 1.1.0                
NuGet\Install-Package Kahia.EmbeddedResourceVirtualPathProvider -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kahia.EmbeddedResourceVirtualPathProvider" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kahia.EmbeddedResourceVirtualPathProvider --version 1.1.0                
#r "nuget: Kahia.EmbeddedResourceVirtualPathProvider, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Kahia.EmbeddedResourceVirtualPathProvider as a Cake Addin
#addin nuget:?package=Kahia.EmbeddedResourceVirtualPathProvider&version=1.1.0

// Install Kahia.EmbeddedResourceVirtualPathProvider as a Cake Tool
#tool nuget:?package=Kahia.EmbeddedResourceVirtualPathProvider&version=1.1.0                

EmbeddedResourceVirtualPathProvider


------ Embedded Virtual Path Provider Readme -----------------

This package enables serving all type of files from assemblies (dlls) just like you are exploring using file explorer; even you can serve aspx, master, ascx files, whatever you wish. For example, if you enable Directory Browsing from IIS for these virtual paths, everyting would work fine.

To start; Global.asax: Application_Start

var provider = EmbeddedResourceVirtualPathProvider.CreateInstance(new Dictionary<string, Assembly>
{
    {"~/common-web-resources/", typeof(Garenta.CommonWebResources.CommonWebResources).Assembly}
});
HostingEnvironment.RegisterVirtualPathProvider(provider);

You have to define mappings of virtual paths with assemblies. I did not try conflicting directory mappings. If you find any bugs, please let me know on GitHub.

Web.config: Allow IIS to process paths for static files

<location path="common-web-resources">
    <system.webServer>
      <handlers>
        <add name="common-web-resources-JS" path="*.js" verb="*" type="System.Web.StaticFileHandler" />
        <add name="common-web-resources-CSS" path="*.css" verb="*" type="System.Web.StaticFileHandler" />
        <add name="common-web-resources-PNG" path="*.png" verb="*" type="System.Web.StaticFileHandler" />
        <add name="common-web-resources-GIF" path="*.gif" verb="*" type="System.Web.StaticFileHandler" />
        <add name="common-web-resources-TXT" path="*.txt" verb="*" type="System.Web.StaticFileHandler" />
        <add name="common-web-resources-SVG" path="*.svg" verb="*" type="System.Web.StaticFileHandler" />
      </handlers>
    </system.webServer>
  </location>

For each virtual path mapping, you have to allow file extensions.

In order to reference such files;

This will be enough;

<script type="text/javascript" src="/common-web-resources/collaboration/collaboration.js "></script> 

But you can also define extension methods for ease of use:

public static string CommonWebResource(this UrlHelper url, string virtualPath)
{
    return CDNHelper.GetResource(virtualPath.Replace("~/", "~/common-web-resources/"));
}
Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 775 12/21/2018