ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

ApplicationBuilderExtensions

.Net Core use package.json files

Source

public static class ApplicationBuilderExtensions
{
    public static IApplicationBuilder UseNodeModules(this IApplicationBuilder app, string root)
    {
        var path = Path.Combine(root, "node_modules");
        var provider = new PhysicalFileProvider(path);

        var options = new StaticFileOptions
        {
            RequestPath = "/node_modules",
            FileProvider = provider
        };

        app.UseStaticFiles(options);

        return app;
    }
}

Example

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    app.UseNodeModules(env.ContentRootPath);


}

Author: Hakan YILMAZ

Submitted on: 27 nov 2018

Language: C#

Type: .net core

Views: 4366