This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
How to use System.Web.Optimization Bundling with Nancy
Simon edited this page Mar 26, 2015
·
14 revisions
Note: Microsoft.AspNet.Web.Optimization requires HttpContext, which is not available with self hosting.
- IF you are using Nancy with OWIN, make sure you use
app.UseNancy(options => options.PassThroughWhenStatusCodesAre(HttpStatusCode.NotFound));
- Install the
Microsoft.AspNet.Web.Optimization
Nuget Package - Setup your bundles in the
ApplicationStartup
Method of your Bootstrapper!
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
BundleTable.Bundles.Add(new ScriptBundle().Add(....));
}
- Add your respective folders to the
StaticContentsConventions
in theConfigureConventions
Method of the Bootstrapper
protected override void ConfigureConventions(NancyConventions nancyConventions)
{
nancyConventions.StaticContentsConventions
.Add(StaticContentConventionBuilder.AddDirectory("/Scripts"));
}
VERY IMPORTANT
Don't forget to add the Urls you provided for the bundles here!
if you used bundles.Add(new ScriptBundle("~/js/mycombinedjsfiles").AddDirectory("~/Scripts/myScripts"))
, you have to add /js
to the StaticContentConventions
too, else the Optimized versions will not work once you go into Release mode!
- Add
System.Web
andSystem.Web.Optimization
to your Razor Assemblies:
<razor disableAutoIncludeModelNamespace="false">
<assemblies>
<add assembly="System.Web.Optimization" />
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
</razor>
https://github.com/stanislavromanov/NancyAspNETWebOptimizationExample
- Introduction
- Exploring the Nancy module
- Routing
- Taking a look at the DynamicDictionary
- Async
- View Engines
- Using Models
- Managing static content
- Authentication
- Lifecycle of a Nancy Application
- Bootstrapper
- Adding a custom FavIcon
- Diagnostics
- Generating a custom error page
- Localization
- SSL Behind Proxy
- Testing your application
- The cryptography helpers
- Validation
- Hosting Nancy with ASP.NET
- Hosting Nancy with WCF
- Hosting Nancy with Azure
- Hosting Nancy with Suave.IO
- Hosting Nancy with OWIN
- Hosting Nancy with Umbraco
- Hosting Nancy with Nginx on Ubuntu
- Hosting Nancy with FastCgi
- Self Hosting Nancy
- Implementing a Host
- Accessing the client certificate when using SSL
- Running Nancy on your Raspberry Pi
- Running Nancy with ASP.NET Core 3.1