FAQ Database Discussion Community


NancyFX error when doing per-route authentication in async route handler

c#,authentication,asynchronous,nancy
When I try to handle a route asynchronously and within that route I do the authentication, Nancy throws a RouteExecutionEarlyExitException and then the status code 500 (Internal Server Error) is returned instead of 401 (Unauthorized). My route handler looks roughly like this: Get["route/to/private/stuff", true] = async (args, ct) => {...

C# IOC and Request State in NancyFX

c#,nancy,tinyioc
I want to inject a class into my module using the IOC framework in NancyFX, and I want that class to have access to the Context, just like the module does. How would I do that? The module has a property called Context, that doesn't seem to be injected (nor...

NancyFX Error: Unable to locate view 'Int32' How do I fix this?

c#,nancy
I'm learning NancyFX and I have a simple route that returns an id that a user requests. Here's the code: using Nancy; namespace NancyFXTutorial { public class CarModule : NancyModule { public CarModule() { Get["/status"] = _ => "Hello World"; Get["/car/{id}"] = parameters => { int id = parameters.id; return...

Enabling https with NancyFx Owin Self-host

ssl,https,owin,nancy
I'm selfhosting a NancyFx service with Owin (on intranet from a Windows 8 machine) and it works fine. Trying to switch to HTTPS but have run into problems. I have: Created self-signed root CA Created exchange-cert using above CA (CN=mycomputer) Exported public key of CA and installed on client-machine Used...

Owin Hosted NancyFX app returns Could not load type Nancy.Hosting.Aspnet.NancyHttpRequestHandler once published to IIS

owin,iis-8,nancy
While it works perfectly when run locally through VS Studio's included IIS Express, my application chokes once deployed to IIS 8: System.Web.HttpException: Could not load type 'Nancy.Hosting.Aspnet.NancyHttpRequestHandler'. Back-end is MS Owin, written in VB (.NET 4.5), which registers 3 middlewares: OAuth server, JWT bearer Authentication, and Nancy. Front end is...

Host sudirectory with Nancy

c#,web,nancy
Hello I am trying to host a simple HTML site with Nancy selfhosting. I also need some js files that a stored in a subdirectory “scripts”. Here is my Bootstrapperfunction for the subdirectory: protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions) { nancyConventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("scripts", "scripts")); base.ConfigureConventions(nancyConventions); } Now if I install Nancy in version...

How to create a Certificate Signing Request (CSR) OWIN Selfhosted

owin,nancy,csr
Would I use the IIS Manager to create this CSR even though the web application is not hosted in IIS? I have a .Net app using NancyFX that is self hosted using Microsoft.Owin.Hosting (so IIS is not used at all) and I need to create a CSR for the production...

Process list of object by type

c#,ninject,web-api,nancy,onion-architecture
I have a requirement to create a Sync method. 1) On input it takes SyncRequest object. class SyncRequest{ public List<SyncObj> Objects{get;set;} } class SyncObj{ public Type Type{get;set;} public object Object{get;set;} } 2) Based on type of each object i need to use different service to proceed and the different repository...

Is there another way to ensure NancyFx SSL for all modules?

c#,security,nancy
I would like to know the correct way of enforcing SSL for all calls to my Nancy API. My current (C#) implementation is: public abstract class NancyHttpsModule : NancyModule { public NancyHttpsModule(string baseUrl) : base(baseUrl) { this.RequiresHttps(); } } This seems to work with 403 Forbidden on the Non-SSL port....

Raw request Body Content

nancy
I'm developing Nancy web service that will collect data from clients which will send HTTP requests like this POST /iclock/cdata?SN=3163602360001&table=OPERLOG&OpStamp=426433018 HTTP/1.1 Host: 218.108.223.49:9001 User-Agent: iClock Proxy/1.09 Connection: close Content-Length: 4883 Accept: */* OPLOG 0\tab 0\tab 2012-09-07 11:36:39\tab 0\tab 0\tab 0\tab 0 OPLOG 3\tab 0\tab 2012-09-07 11:36:42\tab 55\tab 0\tab 0\tab 0...

How to add a request header in Nancyfx?

c#,web,nancy
I tried adding this in the bootstrapper in the ApplicationStartup override. pipelines.AfterRequest.AddItemToStartOfPipeline(ctx => { ctx.Request.Headers["x-fcr-version"] = "1"; }); Its giving me errors. Can anyone point me in the right direction?...

Custom View folder in NancyFx

nancy
I want to use different folders other than Views with NancyFx. I've created a custom bootstrapper and it looks like: using Nancy; namespace MyBootstrapperTest { public class CustomBootstrapper : DefaultNancyBootstrapper { protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions) { nancyConventions.ViewLocationConventions.Add((viewName, model, context)) => string.Concat("html/", viewName)); } } } But Visual Studio is...

Difference between application and module pipelines in Nancy?

c#,asp.net,nancy
I have seen in the documentation of Nancy, sometimes these two are referred distinctively. And also is there a difference in the Before/After hooks of these two pipelines?...

Model binding to Dictionary in Nancy

c#,model-binding,nancy
I can't bind JSON to Dictionary<string,string> in Nancy. This route: Get["testGet"] = _ => { var dictionary = new Dictionary<string, string> { {"hello", "world"}, {"foo", "bar"} }; return Response.AsJson(dictionary); }; returns the following JSON, as expected: { "hello": "world", "foo": "bar" } When I try and post this exact JSON...

NancyFx bind TimeSpan is not Working json

c#,angularjs,model-binding,nancy
Good Morning (here) I'm using NancyFx and i've a problem when i try to bind a class with TimeSpan Properties, i'm using AngularJs too a json that i use is: { "description": "foo", "scheduleTime": { "days": 0, "hours": 23, "minutes": 36, "seconds": 10, "milliseconds": 0 } }; My C# Class...

TypeInitializationException when using Nancy.Testing with NUnit test runner

c#,.net,nunit,nancy
I am writing a test using version 1.2 of Nancy and Nancy.Testing via NuGet. My test is written with NUnit 2.6.4 and looks like this: [Test] public async Task ShouldReturnSuccessfullyAuthenticatedUser() { // arrange var request = CreateRequest(); var userDocument = CreateUserDocumentFrom(request); await userRepository.AddAsync(userDocument); // act var response = browser.Post(Paths.Login, with...

Stream an (SqlFile-)Stream using Nancy

memory,stream,nancy,sqlfilestream
I was wondering how to send an (in my case) SqlFileStream directly to the client through our Nancy-API without loading the stream in memory. So far I succeeded in passing the stream, but Nancy's StreamResponse copies the sourcestream (=SqlFileStream) to the outputstream which causes a massive memory increase. Where I...

Define route that matches file on disk

f#,nancy
I'm trying to decorate some of the files in the public directory by wrapping them in template. Sample filesystem structure: project_root\ file_i_want_to_decorate.html file_that_should_be_just_downloadable.zip The route /{path*} just captures all the files. Not good. So my idea was to use custom matcher: type ContentRouteSegmentConstraint() = inherit RouteSegmentConstraintBase<string>() let root = Environment.GetEnvironmentVariable("PROJECT_ROOT")...

Failing to load byte[] or base64 data in Couchbase using C# client

c#,.net,couchbase,nancy,system.net.sockets
When trying to in/upsert a document using either byte[] or a base64 encoded string I'm getting an exception and a !result.Success Message = "Specified argument was out of the range of valid values.\r\nParameter name: count My document doesn't contain anything named count. This exception all carries an inner exception of...

Is there any significance to naming the DynamicDictionary parameter in NancyFX?

nancy
The documentation for NancyFX seems to switch between giving the DynamicDictionary a full name (parameters) and just using underscore (_) Get["/hello/{name}"] = parameters => { return "Hello " + parameters.name; }; vs Get["/products/{id}"] = _ => { //do something }; Is there any significance to the naming of this parameter?...

Nancy FX enable CORS for static content

cors,nancy
I'm able to allow CORS for my ordinary routes, but not for static content, because the after request pipeline handler is not called for those requests. Any way to enable it? Regards...