nancy

Benefits of using NancyFx? [closed]

孤街醉人 提交于 2019-12-02 21:07:12
There is yet another framework for making HTTP calls called NancyFx. My question is what are the benefits of using it. I had quick look at the documentation: https://github.com/NancyFx/Nancy/wiki/Documentation and it looks like there is no outstanding feature due to which I would like to use this. What are the benefits of using it over WebHttp? P.S: I keep reading about some strange phrase that keep repeating again and again "super-duper-happy-path". Is there anything apart from this "super-duper-happy-path"? Any real features implemented? It appears that it offers a different approach to

How should I handle authentication with Nancy?

扶醉桌前 提交于 2019-12-02 20:26:30
I started coding a LoginModule for Nancy, but it occurred to me that possibly I need to perform authentication a different way. Is there an accepted way of doing auth in Nancy? I am planning two projects right now: web and json service. I will need auth for both. Christian Horsdal As Steven writes Nancy supports basic and form auth out of the box. Have a look these two demo apps to see how to do each: https://github.com/NancyFx/Nancy/tree/master/samples/Nancy.Demo.Authentication.Forms and https://github.com/NancyFx/Nancy/tree/master/samples/Nancy.Demo.Authentication.Basic From the second of

How can I authenticate against Active Directory in Nancy?

青春壹個敷衍的年華 提交于 2019-12-02 18:31:09
It's an outdated article, but http://msdn.microsoft.com/en-us/library/ff650308.aspx#paght000026_step3 illustrates what I want to do. I've chosen Nancy as my web framework because of it's simplicity and low-ceremony approach. So, I need a way to authenticate against Active Directory using Nancy . In ASP.NET, it looks like you can just switch between a db-based membership provider and Active Directory just by some settings in your web.config file. I don't need that specifically, but the ability to switch between dev and production would be amazing. How can this be done? Really the solution is

Returning a string containing valid Json with Nancy

假装没事ソ 提交于 2019-12-02 17:51:30
I receive a string that contains valid JSON from another service. I would like to just forward this string with Nancy but also set the content-type to "application/json" which will allow me to remove the need for using $.parseJSON(data) on the client side. If I use Response.AsJson it seems to mangle the JSON in the string and adds escape characters. I could create a Stream with the string and set the response type something like: Response test = new Response(); test.ContentType = "application/json"; test.Contents = new MemoryStream(Encoding.UTF8.GetBytes(myJsonString)); but would like to know

Nancy test doesn't find route in other assembly

北城余情 提交于 2019-12-02 11:04:56
问题 I have the following spec (using Machine.Specifications or mSpec): public class when_a_user_logs_in_successfully { static Browser _browser; static BrowserResponse _response; Establish context = () => { var bootstrapper = new ConfigurableBootstrapper(); _browser = new Browser(bootstrapper); }; Because of = () => _response = _browser.Get("/Login", with => with.HttpRequest()); It should_return_a_successful_response = () => _response.Body.ShouldNotBeNull(); } The route from the spec should find

How to bind a model to a dynamically created class nancyfx

China☆狼群 提交于 2019-12-02 10:17:23
first of all thanks for anyone who's willing to have a look at my problem. I'm pretty new with Nancyfx and I'm having issues with trying to bind a JSON payload to a dynamically created class. I created the class dynamically by following the code in this post - Dynamically create a class in C# This is my block of code that creates the dynamic class, which I admit is essentially a cut and paste of the code given by danijels public static Type CompileResultType(List<Metadata> metadata) { TypeBuilder tb = GetTypeBuilder(); ConstructorBuilder constructor = tb.DefineDefaultConstructor

How do I call an asynchronous process from an asp.net hosted module using C#5 async / await?

萝らか妹 提交于 2019-12-01 13:44:29
问题 I have a long running process that is called via a Nancy Module Get method. Rather than have the browser hang while the process runs I would like this call to be asynchronous, in other words I want the Get method to return right away and leave the long running process to do its thing. I could then check the status of the process at regular intervals and act accordingly. I am new to the async / await features of C#5 but I feel sure these are meant for just this kind of task. The code below

How do I remotely access self-hosted Nancy service?

拥有回忆 提交于 2019-12-01 11:53:19
I am creating a simple Windows service that hosts a Nancy instance to provide views of its internal data. Everything works as expected when using a browser on the local machine; I see the view that it serves up. However, I cannot find any reason why it will not access from a remote browser (on the same network). Access from a remote browser simply delays a while; IE will eventually display "This page can’t be displayed;" Safari on an iPad shows the partial progress bar for a while and does nothing. I'm binding using all local IPs, not just localhost. I am using the GetUriParams() function at

How do I remotely access self-hosted Nancy service?

一世执手 提交于 2019-12-01 08:02:09
问题 I am creating a simple Windows service that hosts a Nancy instance to provide views of its internal data. Everything works as expected when using a browser on the local machine; I see the view that it serves up. However, I cannot find any reason why it will not access from a remote browser (on the same network). Access from a remote browser simply delays a while; IE will eventually display "This page can’t be displayed;" Safari on an iPad shows the partial progress bar for a while and does

Getting CORS To Work With Nancy

无人久伴 提交于 2019-12-01 03:29:31
I am trying to get all types of requests to work with Nancy and CORS. Currently I add a pipeline at the end of the request: pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) => ctx.Response .WithHeader("Access-Control-Allow-Origin", "http://localhost:57515") .WithHeader("Access-Control-Allow-Methods", "POST, GET, DELETE, PUT, OPTIONS") .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type") .WithHeader("Allow", "POST, GET, DELETE, PUT, OPTIONS")) The options request comes back with a status code of 200, which leads me to believe that it executed fine, but for any type of