Embedded C# web server? [closed] - c#

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
In Java I've been able to embed* the jetty server in my apps, but is there an equivalent embedded* server technology for .Net?
Open source (FLOSS) would be preferred if possible.
*by embedded I mean a lightweight web server app that could be packaged with my application and run on a user's local desktop machine to provide a web service locally.

The closest equivalent to Jetty I've found so far is Nancy, described as:
a lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono.
Nancy is designed to handle DELETE, GET, HEAD, OPTIONS, POST, PUT and PATCH requests
Nancy was designed to not have any dependencies on existing frameworks. Built with the .NET framework client profile, Nancy can be used pretty much wherever you want to, since it’s completely self contained with it’s own request and response objects.
One of the core concepts in Nancy is hosts. A host acts as an adaptor for a hosting environment and Nancy, thus enabling Nancy to run on existing technologies such as ASP.NET, WCF and OWIN, or integrated in any given application.
An even more lightweight option is Kayak (Update: project looks dead as of 2014-01-18), which its documentation describes as:
a simple web server. It listens for connections, creates an in-memory representation of requests, and allows you to easily generate responses. It can be used in any C# program. Your code loads Kayak into its process space—not the other way around!
and both Nancy and Kayak are MIT licensed.

Here's another alternative I wrote last year and and has served me well.
EmbedIO: https://github.com/unosquare/embedio
I use it mostly to create RESTful services on the Raspberry Pi (soft-float).
Edit: Updated code for Mono 3.10, support for WebSockets, and Asynchronous handling of requests.

Update for 2016:
The new kid on the block is Kestrel.
Kestrel is an open source web server that is a part of the ASP NET Core initiative by Microsoft. It is an event based webserver built upon libuv (it basically node.js - js + .net). This means that it should be easily portable between different operating system. Unfortunately, it does mean it requires an external native dependency. *
https://github.com/aspnet/KestrelHttpServer
An older project that does this is Nowin
https://github.com/Bobris/Nowin/tree/master/Nowin
This is an implementation of Owin built entirely within .net. Unfortunately, it has been deprecated in favor for Kestrel.
Edit: * The newest version of Kestrel has dropped libuv for a managed dotnet socket approach. This of course means Kestrel no longer has a native dependency.

The one that is used with Visual Studio is called cassini. There is a good derivative called UltiCassini.

The solution from Microsoft itself is called Katana,
https://katanaproject.codeplex.com/
Note that it is fully open sourced, under Apache license.

Related

Which is better for my scenario - WCF or WebAPI? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
My case is - I'm developing a system that help a car service to communicate with their customers and vice versa. There will be two products - a mobile app written in Xamarin.Forms and a web page in ASP.Net - both doing same things more or less, an alternative. The database will be hosted on SQL Server. And now I'm confused about the "middle" layer. I have been reading a lot about WCF and WebAPI and I still can't figure out which is better for me. Any suggestions for this scenario?
"Better" is always a hard question to answer. So, that's my disclaimer.
WebAPI is currently pretty standard, and quite easy. It allows for simple REST api's - although these are very doable with WCF as well.
The main difference between WCF and Web API
Web API
is, well Web (HTTP) - almost every language supports it, it's relatively light weight.
WCF
It's big - HTTP is just one of the options for binding. It's ideal for enterprise wide connectivity solutions. For example - reusing your logic for HTTP bindings and or message queueing.
One nice feature of WCF is that, at least for C#, it generates client libraries and models for you. It comes with Visual Studio (note: see warning). For the WebAPI, you might need to create the client libraries yourself - which basically be a lot of HTTP calls.
If you want it simple - WebAPI has very good support and can be implemented easily from any language - the clients and models are pretty straight forward - but usually you do need to code them yourself, unless you use OpenAPI spec and some toolkits.
Warning
The generated WCF libraries, might or might not be compatible with the framework (Mono, Xamarin, Core, etc.) you are using. As #Dai mentions, the WCF client library generation might be outdated. Although I do not know if there are more open source tools available to extract clients from the WSDL. So, you should try if your client is compatible first.
For Web API client generation, you can look at tools like Swaggerhub. Do note: you need to define the spec in your application (or provide it explicitly)
See: https://swagger.io/tools/swaggerhub/
The advise (obviously just an opinion)
If you don't need the full package of WCF, the extensive binding capabilities and such, I would go for the WebAPI variant.
If you combine it with Swagger (OpenAPI spec), you'll get a pretty open and easy to use API available for a broad variety of languages.
For more info on swagger/swashbuckle: https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1&tabs=visual-studio

Alternative to HttpListener and Griffin.WebServer in C#

In short, i am looking for the best mehod to provide a REST or SOAP API Server in a .Net Framework application (e.g. windows forms) - without admin rights in some cases
What is currently the best way of providing a web based REST or SOAP API in a possible portable csharp application?
Basically i need something that supports the basic http standards out of the box (e.g. Expect: 100-continue and others) and at the same time is able to instanciate the classes of my csharp program directly (perfomrance and ease of use reasons).
The microsoft way is to either use IIS and possibly ASP or go for httplistener. IIS could never be run in a portable way and requires lots of installation procedure/system administration based work. httlistener on the other hand is not even close to being a webserver, i would need to implement all the standard webserver commands on my own.
I am looking around for this topic since years now, one example is this question [old question] Alternative to HttpListener?
Unfortunately this one links to a discontinued project.
Any ideas?
[EDIT] The question targets not only C# but also .NET Framework 2-4.5. The result should be useable in e.g. Windows Form, Windows Service and Commandline applications.
Currently i am using a skeleton Webserver based on HTTPListener and therefore i need to implement all the Parsing of a request, formatting of answers and reacting to special http commands on my own (which seems to be a never ending task): https://www.codeproject.com/Articles/17071/Sample-HTTP-Server-Skeleton-in-C
You could try Griffin web server. I've used it for embedding a web server into applications to host a simple web interface, file hosting, and to provide a REST API for my application.
The biggest advantage for me versus the embedio project (which is excellent) is that it doesn't require admin privileges to run. Looks like no SOAP integration out of the box though.
You should be able to do what you want using .NET Core. You can fairly easily build a self-hosted API using it that's independent of IIS. Tutorials should be easy to find, and here is a Microsoft example.
As ilikesleeping suggested you could use dotnet core, but there are complications in making it work as a service.
I suggest you to use Microsoft OWIN framework. It's really simple and straightforward way of building restful applications. It can work fine as Console or a service, and of course in Console mkode you can display a Form should you wish to.
Here are some links to get kickstarted:
https://learn.microsoft.com/en-us/aspnet/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api | https://learn.microsoft.com/en-us/aspnet/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana | https://blog.decayingcode.com/post/Creating-a-Self-Hosted-OWIN-Application/ |
https://weblogs.asp.net/fredriknormen/creating-a-simple-rest-like-service-with-owin-open-web-server-interface
EDIT:
...and here's the topic on how to have a middleware that hosts SOAP endpoint over OWIN: Any way to get OWIN to host a SOAP service?
I am the author of this question. Just wanted to make obvious for future readers what i learned here:
Most interesting about this question is that it is a "shopping" question. The accepted answer cannot be based on facts but on subjective feeling only. Most of the suggested methods hit the described usecase.
This is the reason why some users did not want to write an answer but instead put their suggestions in a comment instead. Strange but this is how SO works. We just prefer scientifically correct answers here!
By te way, this was my first "bounty" question. I am active SO user since about 3 weeks. (passive for years, like most people)

ASP.NET MVC 5 Modular Web application Architecture? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
The company where I am currently employed is struggling with an architectural decision for our range of applications. At the moment we have a couple applications that have common parts (think like a calendar module). Until now we kept on copying code from other existing application, but in the future we want to evolve our applications to a more modular design:
As you can see in the picture above it is possible to have different versions of modules per application.
We are considering to possible solutions:
Building a core application framework where we can install our
modules in. We're think about a tool like Nuget to accomplish this.
Building one application where all our modules are included in (=one code base), but the customer only gets the functionality that is activated for him. We're forseeing some problems with versioning here.
Any suggestions on this? We can't be the first company who struggles with this problem?All our applications are ASP.NET MVC 4/5 web applications, built with Razor Templates or JavaScript templates (knockout.js). All of our applications are deployed on Microsoft Azure and we have extensive inhouse knowledge of buildscripts (MSBuild), CI Servers...
Having separate project/assembly for each module and delivering it as Nuget package is definitely a good strategy.
Advantage:
Can maintain and release multiple version. Different client get different version.
Installation of latest or specific version supported through Nuget. This helps during development where App A developer can target 2.0 version of module A while App B developer can target 1.0.
Single source base with separate branches for each version. Client using 1.0 request a change will get code from branch 1.0 with just the fix requested.
Each module can be released or updated independently.
Challenges:
During development debugging assembly code that's installed using Nuget. Nuget supports it inbuilt. We achieved it in our case (Framework being used by multiple platform).
Code changes required in module code (a bug or a new feature required). Well this is tricky:
Option 1: Same developer just go ahead and make that change, create new package and install new version in his app. Got to authorize the change as it is critical code.
Option 2: A designated team responsible to fix issue or change request in framework code.
You can also try using the plugin architecture, just build the different modules that makes up the application as a plugin, then build the module that is required for every application as a single code base. In this case, installing a component for any particular user, will be a matter of adding or pulling out plugins. Many large projects makes you of this particular architecture as it reduces copy and paste, increases and reuse and speed of development. You can check nopcommerce an open source project for an idea of how it is done.

Distributed Monitoring Service using C# .NET 3.5 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Let's say for example you have 5 different companies using the same platform (Windows based) all wrote their own web services, what technique using C# and .Net 3.5 would you recommend using to monitor all their different web services?
My intention is to build an application that provides visual feedback on service statuses to site administrators and of course e-mail/sms alerts as needed. Is there a best practice or methodology to follow in your opinion?
In addition, are there any windows based tools available to perform this that I'm unaware off? Preferrably open-source?
*Edit: Think of the end result, an application that just shows a red or green light next to the services running across the different companies.
Company 1
> Web Service 1 - Green
> Web Service 2 - Green
Company 2
> Web Service 1 - Red
> Web Service 2 - Green
You should try PolyMon, a .NET based, open-source monitoring tool on CodePlex:
http://polymon.codeplex.com/
At least for our case, it hit the sweet-spot of functionality and a lean and easy setup.
You can choose from some out-of-the-box tasks like Ping or URL monitoring, but you can also easily implement your own more complex tasks. Works quite well for us.
The tool itself is not distributed, but you can easily set up two instances of the service (e. g. on servers in different locations) and monitor the same services, or use one instance to monitor the other.
We experienced just one issue that was very annoying and a little freaky, when a server that was running both PolyMon and the SQL Server instance used by PolyMon repeatedly crashed on reboots (endless loop of reboot). Seems to be some kind of race condition. Therefore I strongly recommend to host the PolyMon service and the SQL Server service on different (virtual) machines, or set the start-up type of the PolyMon service to "Manual" instead of "Automatic", and start PolyMon manually after everything else booted, to avoid this problem.
Big Brother System and Network Monitor, will probably do most of what you want. It is extensible and plug-ins can be written in any language. They have a free editon of their monitoring software:
http://www.bb4.org/home1.html
You should also use a local monitor on each server that is being monitored. This is because it is difficult to diagnose problems remotely. This blog has a good discussion of the problem and details of a local monitor design pattern:
http://sleeksoft.co.uk/public/techblog/articles/20041218_1.html
The most commonly used open source monitoring tool is Nagios. Built in it has support for many different services, and you can always write a script or app to test any service not already supported.
Nagios Home Page
Windows Monitoring Service
Instruction for setting up Windows service
If they write aspx web services, all monitoring best practices described for ASP.NET applications, like ASP.NET Health Monitoring Overview MSDN article and in ASP.NET Health Monitoring are applicable
Also see an SO question Tools and methods for live-monitoring ASP.NET web applications?
Standard tools will allow you to ping the IP or probe the HTTP port - these are cheap & simple ways of verifying that the web service is minimally available. In order to validate that they are also fully functional, you will need to do a bit more... your monitoring package will need valid credentials to login to the various web services, not to mention specific proxies & business logic to execute against each one.
Have you looked at MOM (especially MOM management packs)?
There are tools like IPSentry with which you can make HTTP requests and check the returning data...
I know this is a pretty old thread but thought I would add Wolfpack to the list for anyone still looking for a "distributed system monitor" - Wolfpack was designed (by me) as exactly that. It can run multiple "agents" collecting data about the servers they monitor and reporting it to a central server instance.
It has a rich set of monitoring and storage plugins and you can easily roll your own for custom checks (there are numerous supporting nuget packages available - just search for Wolfpack on nuget.org) plus there is an active contrib project too...and its really easy to install via chocolatey.org (cinst wolfpack)!
It is open source and completely FREE! I'm also rewriting major parts of it at the moment for the next v3.0 release and it will support SignalR alert notifications, powershell and a full web api/interface (via ServiceStack).

Is there a .NET equivalent to Apache Hadoop? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
So, I've been looking at Hadoop with keen interest, and to be honest I'm fascinated, things don't get much cooler.
My only minor issue is I'm a C# developer and it's in Java.
It's not that I don't understand the Java as much as I'm looking for the Hadoop.net or NHadoop or the .NET project that embraces the Google MapReduce approach. Does anyone know of one?
Have you looked at using Hadoop's streaming?
I use it in python all the time :-).
I'm starting to see that the heterogeneous approach is often the best and it looks like other folks are doing the same.
If you look at projects like protocol-buffers or facebook's thrift you see that sometimes it's just best to use an app written in another language and build the glue in the language of your preference.
Recently, MySpace released their .NET MapReduce framework, Qizmt, as Open Source, so this is also a potential contender in this space.
See http://research.microsoft.com/en-us/projects/dryadlinq/default.aspx or http://msdn.microsoft.com/en-us/library/dd179423.aspx
I answered your question in my question here
To say it here in the source:
Microsoft dropped its alternative (Dryad) in favor of Hadoop.
Next year they will release MS SQL Server 2012 with Hadoop integration. Azure and Windows Sever support is being developed even as we speak.
It will be available in the first half in 2012.
Hadoop is the #1 BigData platform and is going to be supported by opensource and proprietary source (Java, .Net, Python, ...) even Oracle is adopting it.
If you were developing something, you should wait if you're on the .Net platform.
More information about what is possible will be available here
I would say that DryadLinq is the closest thing that us .NET folk have to Hadoop. But it depends what you want to use hadoop for. If you are looking for the optimized self maintaining distributed file (DFS) system then DryadLINQ isn't what you are looking for. It has an analog to the DFS but you have to manually build the partitions and distribute each partition.
That being said, if its the distributed execution aspect of Hadoop that you are looking for than DryadLINQ is truly wonderful (and no, i'm not affiliated with MS). As long as you have a Microsoft HPC cluster setup than getting going with DryadLINQ is really easy.
The code you write is really just straight LINQ code, except instead of executing the LINQ on IEnumerable<T> you have to execute it on PartitionedTable<T> (the self build distributed data structure).
What has really been cool about DryadLINQ is the fast turn around time (try, test, adjust, repeat) when developing algorithms. You just write LINQ code to do your calculations and DryadLINQ will take care of the whole distributed execution part. It's the most natural analog I've come across that makes writing code for distributed processing just like writing code for single process processing.
You can look into something like RavenDb it provides very decent support for MapReduce for a fairly large size of data. as it is built in .Net so a proper LINQ client API is available.
http://ravendb.net/
To get you started you can read my blog entery.
It may be better to use Apache Hadoop and streaming because Apache Hadoop is actively being developed and maintained by big giants in the Industry like Yahoo and Facebook. So it can do what you expect it to do.
If you need a solution in .NET please check Myspace implementation # MySpace Qizmt - MySpace’s Open Source Mapreduce Framework
Microsoft is in the process of rolling out HDInsight, which is billed as their "100% Apache compatible Hadoop distribution."
It is available both on Windows Server and as a Windows Azure service.
Microsoft Research has project Daytona
http://research.microsoft.com/en-us/projects/daytona/
You can download it. There's a WordCount sample in C#.
You can now use Hadoop directly from .NET Microsoft has release a SDK to do so.
https://hadoopsdk.codeplex.com/
Of course this means using the java based Hadoop network. But does it matter if the server is running in java? I am sure someone may attempt to port it but I don't think it would be a good idea as corporations are already backing the java version and I don't think the .NET port will get the same attention.
Have a look on:
http://www.windowsazure.com/en-us/services/hdinsight/
It is an implementation of Hadoop for Azure and you can use .NET for accessing it.
Internally, Microsoft have been using Cosmos. This has been made available outside Microsoft thru Azure. It's named Azure Data Lake Analytics and Azure Data Lake Store. Azure Data Lake analytics is kind of Yarn as a service and Azure Data Lake Store WebHDFS as a service. The first version of Azure Data Lake Analytics only hosts U-SQL a language based on Transact-SQL + C#.
There's a pretty cute MapReduce implementation for .NET at: http://mapsharp.codeplex.com/
dryad/linq is being productized and will be released soon:
http://blogs.technet.com/b/windowshpc/archive/2011/07/07/announcing-linq-to-hpc-beta-2.aspx
use in conjunction with Microsoft HPC for a powerful, cluster based solution for quering unstructured data
As others have mentioned, DryadLINQ is a programming framework that allows developers to write LINQ queries and execute them on a cluster, in a similar manner to MapReduce. The DryadLINQ project has recently been released under the Apache license on GitHub, and the release includes support for running on YARN clusters (including Azure HDInsight clusters).

Categories

Resources