Web server integration in Windows application - c#

I am developing a Windows application using the .NET framework. I am exploring the best ways to integrate a web server in my application that listens to localhost:8080 (or whatever port). I do not want to compromise on the security of the user so I would like to use some library or existing web server application that is secure and does not have vulnerabilities.
So I rounded myself to 2 ways -
1) Using a popular web-server like nginx or apache - and invoking it through the application (and running it as a process with CreateNoWindow = true;).
2) Using a web server written in C# or C++ like WebServer.
What would be the best way to do it? I am open to more suggestions.

I have done this 3 ways in .NET
If it's a web service or Data service your can use the ServiceHost to host your own endpoints
IIS Express is probably the most robust and "proper" solution, unfortunately it's still in beta. You can get it by downloading Webmatrix. http://www.asp.net/WebMatrix
The source code for the webserver embedded in Visual studio is available, it's called Cassini. I've used it on a few projects. It's available as source or even packaged:
http://code.google.com/p/cassini/
http://ultidev.com/Products/Cassini/

Related

Infrastructure to .NET CORE projects

I haven't been able to find any information on what is required to deploy a .NET CORE solution to a linux environment. I was asked to specify and detail on the requirements to go to production.
We are developing a .NET CORE Web API wich hits a SQL Server database, the client will be an Angular 2 app. I read about .NET CORE is cross-platform, so besides to Windows one could deploy to Linux and OS X. I guess Kestrel is the main piece here, but I'm not very sure of what is the correct infrastructure to deploy.
Do I need multiple servers?, one for the API, one for the DB since SQL Server isn't cross-platform, one for the client app? Additionally, do the severs will need any special configuration?
Shortly: What do I need to ask to our company infrastructure team in order to avoid any misconfiguration when going to prod?
Thanks in advance.
Do I need multiple servers?, one for the API, one for the DB since SQL Server isn't cross-platform, one for the client app?
If you host MSSQL Server on Windows - yes, you would need at least 2 machines. One with Windows and one with Linux, given that you must host your API on Linux. For the client app you do not need a separate server and you can host it on the same server as API.
Also, you can host everything on Windows (MSSQL Server, API, Angular app).
You can take a look at MSSQL Server preview for Linux. MSSQL Server on linux
Additionally, do the severs will need any special configuration?
No, you can just build your .net core api for linux and copy it to the linux server and it will work. For the web server you would need any reverse proxy like NGinx or HAProxy. Here is a good tutorial from Microsoft Linux environment + nginx

C# web application without IIS

For web application development using C#, IIS seems to be the standard choice of web server. But are there any other options? I want to use Linux for my web server.
As far as I can see the other options are:
Make your web server program handle the IIS stuff yourself. (As long as you don't need a lot of IIS features, this won't be too expensive)
Use XSP
Use Apache Tomcat with mod_mono
Use another web server like nginx or lighttpd (Is this even possible with C#?)
Use that OWIN stuff (Are there implementations of this which are mature enough to consider yet?)
Something else I haven't considered ... ?
Which of these options is the most viable for a web application in the long term?
I'm mostly concerned about the long term maintainability of the project, rather than the server being able to handle high volume loads.
Option 1
Install Mono+XSP
Launch ASP.NET web-app using XSP on different port e.g. 8001
Proxy this port through nginx to 80
Option 2 (Better)
Wait for ASP.NET 5 (MVC6) release with complete Linux support
Use standalone-application approach (OWIN-Like) on different port e.g. 8001
Proxy this port through nginx to 80
On both ways you will need to install Mono, and I recommend installing latest one, not the one that, for example, Ubuntu PPA gives.
Also, since you are concerned about long-term you should really wait for Option 2 since it's going to be released in next couple of months.
If you really cannot wait those months and do not want to work on beta-product and then migrate to stable only option I see is NancyFX which is web-app framework written in C# that has full Linux support now.

Application Server equivalent on Windows

I have a question regarding how to write a windows server side application.
We have now have a system whose client is .NET 4.0 based and a server side application running on jboss on Linux. The server application talks to an Oracle DB.
I am now thinking to move the server side to Windows and DB to SQL server. The server application should be written in C# on .NET as well. However, there seems no Application Server equivalent on Windows. How is a server application normally written and deployed on Windows?
Many thanks
There are a few options, but the very basics would be
Host WCF web services in IIS and take advantage of the management IIS offers, you can bring AppFabric into the picture for more robust and manageable hosting.
Self host your service in a Windows Service.
If it suites your application I would say the AppFabric solution is worth looking at. But this is not a 1-to-1 with with a Java Application Server.
Update
Self hosting WCF is as simple as the follow
host = new ServiceHost(typeof(YourWcfService));
host.Open();
This assumes that you have defined a service called YourWcfService'. The above code in theOnStart` of a Windows Service will start accepting requests to your service. Of course this still requires all the basic configuration in the app.config file.
AppFabric, however gives you a nice environment to manage and monitor your services, so not to sound like a broken record, but I would look into it to see if it is possibly a good fit for you.
Update 2:
I did a quick bing and found this MSDN post, it is oldish but looks like a good example.
http://msdn.microsoft.com/en-us/library/bb332338.aspx
It's not exactly true, there are couple of almost unknow but powerful tools that you can use free:
NetFluid: http://www.netfluid.org/
Service Stack: http://www.servicestack.net

An alternative to iis/asp.net/asp while still being able to code in C#

Is there any alternative to IIS/ASP.Net/ASP while still being able to code in C# (for web back end development) ? Is there any light weight open source alternative to IIS,ASP.Net combo ?
Mono is the open source alternative Mono project
Have you tried the new IIS Express? It provides you with a configurable IIS 7.5 style platform per website solution. It's really useful when developing on XP for instance where previously you would have been limited to 1 website per development machine.
It's now available as part of the Visual Studio 2010 SP 1 download.
Check it out here;
IIS Express Overview
Although I'm a bit unclear as to your actual project requirements there is nothing stopping you from creating a C# based application and then exposing a web service which your application could connect to written in any web based language of your choice. However you will still have to host the web service in IIS.
You can use Cassini:
http://ultidev.com/products/Cassini/index.htm
Cassini is very reliable but not designed for heavy usage which is why UltiDev have built UWS Ultidev Web Server Pro based on the original Cassini Server:
http://ultidev.com/products/UWS/

Make C# web application to communicate with a Windows Form via named pipes?

I am new to programming. Right now I am stuck with developing a C# web application that should be able to communicate with a Windows Form via named pipes? Can this be possible? If possible, how?
Note: Web application will be on the server and Windows Form will be on the client.
I could be wrong, but named pipes (specifically, the NetNamedPipeBinding in WCF - thanks Chris) are strictly inter-process IIRC.
You'd be better off a hosting WCF service on the server and connecting to that via the web-app and the Windows Forms app (assuming you can work with .Net 4).
Does this article help?
Taken from there:
(...) working code which you can
download and view.
PipeClient.zip and
PipeServer.zip
These zip files each contain a Visual
Studio 2005 solution with working code
and a GUI for testing communication
between the client and the server.

Categories

Resources