Deploy ASP.NET MVC on Linux: Best Practices, Tools & Surprises - asp.net

I'm wondering about best practices to develop ASP.NET MVC apps with an option to deploy on Linux. If you are creating these kinds of MVC apps,
What Linux/Mono platform are you targeting?
How much of the development are you doing on Windows and how much on Linux?
Are you using an ORM to abstract the database? Which one?
Are you running a build engine on Linux? What about tests?
What other tools are you using?
How much additional work has it been to target Linux in addition to Windows?
What ugly or pleasant surprises have you encountered?

The company I work for targets Mono on Linux as our main deployment environment. Thus there is no "additional" work - we provide the whole stack, from hardware, through operating system (customized and trimmed) to applications. Using Open Source gives huge savings for us and our clients (and yes, we do contribute back to the OS Projects we rely on).
The important thing is to constantly test using your actual target (sorry, Mono on Windows doesn't count). Sure, developers use Visual Studio, but the continous integration (using CruiseControl.Net, you'll need Mono 2.4.2 to run it on Linux) is done both on Windows and Linux, testing all Mono versions we expect to work on (it got much more stable recently, but still, regressions do happen between releases). It's quite easy to run parallel Mono versions on one *nix system, you can even include an svn snapshot build if you prefer to catch upstream regressions early. If you don't roll out your own distribution, then remember that most Linux vendors ship Mono with custom patches - this has caused problems for us before. Also, many distributions have a lot of lag updating Mono, and this is a rapidly advancing project.
For database layer we use mostly "plain" ADO.NET - Oracle (with dotConnect for Oracle, they support Mono) and SQLite (Mono ships with a working connector). I have also used the official ADO.NET Driver for MySQL (Connector/NET) and it, too, works well. ORM mappings are more tricky, but NHibernate is usable (keep in mind that they do not support Mono officially).
As for the build engine and tests - NAnt and NUnit are well known and well tested. With most recent versions of Mono xbuild (clone of MSBuild) actually got usable, but prepare yourself for contributing quite a lot patches if you decide to use it for more complex scenarios.
Write tests. Lots of them. Be prepared to contribute patches and bugreports, and if you use commercial components - make sure the supplier officially supports Mono.

Nathan Bridgewater's blog has some nice articles showing, among other things:
running MVC3 with razor on mono
migrating ASP.NET MVC from Windows/SQL Server to Linux/MySQL
installing and running MonoDevelop
installing mono from source
http://iws.io/get-mvc3-razor-running-on-mono/

Take a look at the Mono project. Sounds like that is what you are looking for. If I remember correctly, they have ASP.NET MVC integrated into it now.
I have never worked with Mono, but from my understanding there are not many differences.

Related

Tools for .NetCore / .NetStandard libraries obfuscation

Currently we were using SmartAssembly from RedGate to obfuscate out .Net Framework based libraries and it worked just fine.
However, in the past months we started working on supporting .NetCore and .NetStandard to be able to scale our product and noticed that we cannot longer obfuscate the resulting libraries because SmartAssembly doesn't support it yet.
Dotfuscator from what I know, could do the job, however it's not taking care of the relationships between dependencies so it's not actually a full obfuscation.
What other tools is the community using to achieve this purpose? I'm interested in free and commercial tools as well.

Developing ASP.NET application for a Linux Server [duplicate]

This question's answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions.
For a developer with a Java background, I am interested in exploring software development using the ASP.NET tools/platform as well.
Java web applications (.jsp and servlets) can run on many server platforms.
Question: Will a .NET web application be able to run in a Linux based server? Considering the scenario of not being able to use a Windows server for hosting a web app.
So I know this is an older question but I think it could stand an updated answer.
Microsoft has officially released asp.net vnext and its open source and deploy-able to both Linux and Mac. Its all still pretty new but does rely on the latest builds of mono and thus currently needs you to compile the mono-framework but in time I suspect that it will be easier to access as various linux distros release updated versions of mono. This is a how to setup guide
This information may be somewhat volatile and with updates is due to change.
Update ASP.NET CORE 11/10/2017
asp.net vnext is now known as asp.net core.
asp.net core is being treated as a high priority in Microsoft due in part to its use with microservice architecture and docker and container technologies
It has become much more compatible with existing .net libraries due to .net standard 2.0.
It performs well when compared to other technology stacks such as go and node.js
It depends what specific .NET technologies you're using. The Mono Project provides an Apache module (mod_mono) for running ASP.NET sites, and from what I gather it works well.
Mono doesn't support all the .NET APIs, though - notably WPF (and possibly WCF too, I can't remember) - but it does provide good support for much else of the framework.
If you're starting from scratch and particularly want to target non-Windows servers, then ensuring your project works with Mono would be a good goal to aim for. However, if you need particular APIs or language features that are not supported by Mono, then you will need to use a Windows server for deployment. It's a design-time/architectural choice that should make up front.
You might want to consider this guide that helps Windows developers port their code to Mono/Linux:
Guide: Porting ASP.NET Applications - Mono
I can speak from experience. Even if your ASP.net website only uses .NET libraries supported by Mono you are going to have a hard time getting it to run if its anything beyond Hello World.
You won't have to re-write much code but you will spend hours/days/weeks dealing with little issues with mod_mono/xsp/apache configuration and file permissions and error handling and all the little things that go into a large website. (Be prepared to spend a lot of time asking questions on serverfault :) )
The problem is that a lot of people don't use Mono for ASP.net websites and so there aren't as many people reporting bugs so a lot of things that are minor bugs go un-fixed for a long time.
Now you can publish ASP.NET 5 app to Docker on Linux with Visual Studio. See the below post from Scott Haselman
http://www.hanselman.com/blog/PublishingAnASPNET5AppToDockerOnLinuxWithVisualStudio.aspx
Since the technologies evolve and this question is top ranked in google, we need to include beyond the mono the new asp.net core, which is a complete rewrite of the asp.net to run for production in Linux and Windows and for development for Linux, Windows and Mac:
You can develop and run your ASP.NET Core apps cross-platform on
Windows, Mac and Linux. ASP.NET Core is open source at GitHub.
Yes we can. get familiar with Mono Project and read this article to get started.
For ASP.NET on Linux, check out Mono.
That said, thousands of sites run on Windows Server without any issues. A poorly-configured server with any OS will be vulnerable; Linux won't save you from a poor admin.
So I guess my "best practice" for deplying an ASP.NET app would be to use Windows Server 2008 (likely Web edition). And hire a good administrator.
You can use Mono to run ASP.NET applications on Apache/Linux, however it has a limited subset of what you can do under Windows. As for "they" saying Windows is more vulnerable to attack - it's not true. IIS has had less security problems over the last couple of years that Apache, but in either case it's all down to the administration of the boxes - both OSes can be easily secured. These days the attack points are not the OS or web server software, but the applications themselves.
dotnet is the official home of .NET on GitHub. It's a great starting point to find many .NET OSS projects from Microsoft and the community, including many that are part of the .NET Foundation.
This may be a great start to support Linux.
Now a days .Net is run in multiple platforms,like linux ,Mac os etc.
but mono is not fully platform independent ,Because to deploy .NET in another OS required
third party software.so it is not like java platform independent.
Mono is running in different platform ,because of JIT is there in different os.
Mono is not fully success in moonlight(silver light in .NET) .Not only Research is going on.
Mono uses XSP2 server or apache . some of the big companies are using this project,Some of the robotic project are also running on mono.
For more details http://www.mono-project.com/Main_Page.
There is the Mono Project from Novell that will allow you to run ASP.Net on Apache.
http://www.mono-project.com/Main_Page
The Mono project is your best option. However, it has a lot of pitfalls (like incomplete API support in some areas), and it's legally gray (people like Richard Stallman have derided the use of Mono because of the possibility of Microsoft coming down on Mono by using its patent rights, but that's another story).
Anyway, Apache supports .NET/Mono through a module, but the last time I checked the version supplied with Debian, it gave Perl language support only; I can't say if it's changed since, perhaps someone else can correct me there.

How to port to .NET core?

I was looking for possibilities for porting some web projects from Windows .NET framework to Ubuntu linux using open source .NET core
After a lot of struggle with Mono, which I have almost gave up. I was looking at .NET core as a new hope. Have anyone of us ported from .NET to .NET core?
If yes, can the possible problems like the ones I faced with Mono be shared?
Moving from .NET to .NET Core is a huge move, especially if you're going to take advantage of Core. There is not currently a one click port, and I doubt you'll ever get a one-click migration like migrating from a VS 2013 project to a VS 2015 project. The entire startup flow is different, and to automate switching to that would be incredibly difficult. For now, the way I am looking at it is that moving to .NET Core is essentially a rewrite. As to whether that is worth it to you for your project - well that's really hard to say and also probably not well suited to that site.
That said, if you do rewrite you can probably bring along a lot of your business logic. You just will need to redo a lot of the other structure.
There's no easy way to move a project from .NET Framework to .NET Core. Possibly you'll need to rewrite or start from scratch.
There are some major differences between two
Format of configuration files (web.config vs appsettings.json)
Used libraries
Startup files (Global.asax vs Startup.cs)
Lack of static objects in .Net Core. Like Session and Application
objects - which is a good thing btw.
Many of the .Net Framework libraries are dependant on
app.config/web.config files

migrating Microsoft apps from windows 2003 server to windows 2012 server

we have more than 30 classic asp and .net applications to be migrated to windows 2012 server from 2003 server.This is new task for me, so what are the steps/factors i need to consider or fulfill for this migration? with that I mean like there are COM objects, dependent dll's all stuff so what things I should ensure are in place for smooth migration.
Microsoft provides ACT tool for Application Compatibility test how much will that support? or are there any other better proven tools for the same purpose?
any insight/help would be appreciative.
Thanks.
First thing to assess is "what works and what doesn't work". There's a high chance that many of these apps will just work. That's the first thing to go do. Start by coming up with some test criteria by which the program is expected to work. Then deploy to the new OS.
One problematic area might be that these executable program require an older version of .NET or the MSVCRT DLLs that might not be on the box by default. The MSVCRT redist is easily available from Micrsoft's web site. You can install older versions of .NET from Control Panel->Programs and Features->"Turn Windows features on or off". Look for the ".NET" checkboxes near the top.
For classic ASP applications, same thing in the "Turn Windows features on or off". Look at "World Wide Web Services" node and make sure ASP (and most all of those other features) is selected.
Microsoft provides ACT tool for Application Compatibility test how much will that support? or are there any other better proven tools for the same purpose?
In my experience with automation tools, especially when working with older sets of technology (like classic asp)they rarely work near as well as advertised.

Embedded database for a simple portable application

I am going to develop small WPF application. Target platform is .NET 3.5. The main goal is to make it portable (move to any folder and it works out of the box). It should run on Windows 7 machine without any additional installations. However I need a database into it (not need ORM support, just simple storage). Could you please suggest database that would be better for this purpose? I think about SQL CE 4.0 but I am not sure whether it requires additional installations like C++ libs or not. Including DLLs is OK.

Resources