Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mono, asp.net c# and MVC How to's and Tutorials

I have a few basic questions for anyone familiar with Mono or Mono Development (whatever it's called) when it comes to programming in .net and deploying in linux (and mac if you know too). A bit about myself, I work mostly with MVC3 and MVC4, a few windows forms, and perhaps in the future mobile apps. 98% of the time in c# and the rest c++.

1) Are you likely to get more bugs and errors versus just sticking with a windows deployment? And if so, how bad are some of the bugs, have you had projects where it doesn't work at all?

2) Do you recommend programming in Visual Studio and then deploy it to a mono platform? Or is there a better IDE you recommend, like Mono (or Eclipse if possible)? Currently I use Linux as my OS and run Windows 7 with Visual Studio.

3) As I have several apps that are completed using .net 4.5 beta and mvc4 beta, are these compatible with the current version of Mono? If not what are the average time frames from when a framework is officially released till Mono becomes compatible?

4) I am not knowledgeable about databases. My databases are for SQL Server, would I have to change them to run on a linux server. Is this a pain or error prone? My sql server databases are created using entity code first, does this work if I have to create MySQL databases (or whatever)?

5) Currently I deploy my mvc websites to a Server 2008r2 remote server. Is there an alternative to IIS that you would use for linux? Can you provide me with a link to a tutorial on setting this up.

6) If question 4 is possible, what are the losses with deploying a MVC website on linux? Speed, reliability, security, etc?

7) Can you give me an estimate on how much disk space the mono + some kind of iis + framework etc. that this would take up? In a comparison of a Linux OS to a Windows OS, Windows takes up a TON more space; so would using this mono setup take up a TON of disk space too? (I understand the OS size comparison is not a good example.)

8) Are there any drawbacks that I may have overlooked, that you can think of? Like is there any strange problems with directory browsing, config file hirearchy, jquery/ajax issues, etc.

9) Do you have any recommendations, tutorials, blogs, etc? Is there a Stack Exchange site that deals with these types of issues better than this one? (I couldn't find one, other than perhaps the Linux one.

10) Although it is not a necessity for me to do this, I would like to set it up and do it just to have the option in the future but I won't waste my time on it if it is a complete waste. I have both a linux VPS and Windows VPS that I rent right now, so if I did this it would also allow me to have only a Linux remote server (possibly with less hard drive space and ram) so it would potentially save me money. So my final question is, would you recommend doing this if your situation was similar to mine?

Please answer any of the questions that you can, Thanks in advance and sorry for so many questions, Garrett Fogerlie

like image 481
Garrett Fogerlie Avatar asked Mar 18 '12 15:03

Garrett Fogerlie


People also ask

Does ASP.NET support Mono?

Supported VersionsMono supports ASP.NET 2.0, ASP.NET AJAX and a handful of 3.5 controls.

What is Mono C#?

Mono is a software platform designed to allow developers to easily create cross platform applications part of the . NET Foundation. Sponsored by Microsoft, Mono is an open source implementation of Microsoft's . NET Framework based on the ECMA standards for C# and the Common Language Runtime.

Is Mono same as .NET Core?

NET Core, which natively only allows you to build console apps and web applications, mono allows you to build many application types available in . NET Framework, including GUI-enabled desktop apps. So, if mono can do everything that . NET Core can while .

What version of .NET does Mono use?

The easiest way to describe what Mono currently supports is: Everything in . NET 4.7 except WPF, WWF, and with limited WCF and limited ASP.NET async stack.


1 Answers

First of all, very good questions.

I do not have experience with web using ASP.Net MVC but I do have experience with ASP.Net web forms and the migration of a commercial ASP.Net application from Windows to Mono running on Linux.

I can answer some of your questions.

1) Are you likely to get more bugs and errors versus just sticking with a windows deployment? And if so, how bad are some of the bugs, have you had projects where it doesn't work at all?

I would say yes but not many. Our application is 200K + lines of code and currently I can only think of one Mono bug that exists with our code which is minor. The bug is calling the Session.Abandon method which crashes Apache. I think that you will find more bugs in the newer .Net API's but overall the framework is very stable.

2) Do you recommend programming in Visual Studio and then deploy it to a mono platform? Or is there a better IDE you recommend, like Mono (or Eclipse if possible)? Currently I use Linux as my OS and run Windows 7 with Visual Studio.

I believe that there is no better IDE than Visual Studio in terms of the features/stability that it offers. However in saying this MonoDevelop is a very good IDE that is very similar to Visual Studio. It just lacks a lot of the extra features that Visual Studio offers. For example a Visual Designer for web pages and attach to process debugging. At the company I work for we use MonoDevelop on Windows/Mac and Linux. So if you are looking for a cross platform solution then go with MonoDevelop but if you don't mind using Windows as your development PC and paying for VS licenses then VS is fine.

Edit: As of writing Visual Studio Community Edition has been released and requires no license. There is also the possibility of using .NET Core in conjunction with your favourite editor (or Visual Studio Code, also free). The latter is supported on Windows, Linux and Mac OS X). There is also now Visual Studio for Mac.

3) As I have several apps that are completed using .net 4.5 beta and mvc4 beta, are these compatible with the current version of Mono? If not what are the average time frames from when a framework is officially released till Mono becomes compatible?

I don't know if these API's are supported yet. One way to find out is using the Moma tool to analyze your assemblies. The other option would be to download the latest version of Mono + MonoDevelop and try to build your solution using them. I don't know of an exact time frame that API's are released but I think generally it is very soon after the .Net release and sometimes even before Microsoft releases.

4) I am not knowledgeable about databases. My databases are for SQL Server, would I have to change them to run on a linux server. Is this a pain or error prone? My sql server databases are created using entity code first, does this work if I have to create MySQL databases (or whatever)?

--> the answer should be no actually. MS released MS-SQL Server for Linux. you can download MSSQL on ubuntu in a matter of 2 apt-get commands. I do not know how to edit this part of the answer. <-- Yes it is a pain switching databases. Even more of a pain if you are using stored procedures. There are commercial programs that can convert your database tables and data from MS SQL Server to MySQL or Postgresql. We used the tools from DBConvert to convert our database schema to Postgresql. Converting the tables was the easy part. The hardest part was converting our stored procedures. Our application relies heavily on stored procedures with 900+ stored procedures in our database. I had to rewrite every stored procedure in Postgresql by hand. If your stored procedures are just straight SQL then it won't be as diffcult but if you rely heavily on TSQL then you will need to find equivalents to your code in the coding language used by the database that you choose. With Postgresql the best equivalent is PL/pgSQL. I haven't had experience with migrating the data using the commercial tools that DBConvert offers. We made a lot of changes to our database at the same time we migrated to Mono so for the data migration we wrote our own code to do the migration.

5) Currently I deploy my mvc websites to a Server 2008r2 remote server. Is there an alternative to IIS that you would use for linux? Can you provide me with a link to a tutorial on setting this up.

&&

7) Can you give me an estimate on how much disk space the mono + some kind of iis + framework etc. that this would take up? In a comparison of a Linux OS to a Windows OS, Windows takes up a TON more space; so would using this mono setup take up a TON of disk space too? (I understand the OS size comparison is not a good example.)

Apache2 with mod_mono is used to host websites with Mono on Linux. Linux uses minimal space. We are hosting our web application using Amazon EC2. A new installation of our stack which basically includes Ubuntu, Mono, Apache2, Postgresql and Postfix only takes up 1.2 GB of space. So the answer is No Mono does not take up a huge amount of disk space. Here is a tutorial on setting up Mono on Ubuntu. I don't know of any tutorials that are exceptionally good. If you need help with this the best places to go to are the Mono IRC channel and the Mono mailing lists. Here you can speak with the community and the developers who work at Xamarin.

8) Are there any drawbacks that I may have overlooked, that you can think of? Like is there any strange problems with directory browsing, config file hirearchy, jquery/ajax issues, etc.

Case sensitivity could be an issue. Linux is a case sensitive OS so you need to make sure that all file system calls are case sensitive. Depending on which database you choose it too could be case sensitive. Postgresql is a case sensitive database so when executing queries the column names have to be case sensitive. With MVC URLs are not case sensitive so you should be fine with that. ASP.Net websites are case sensitive as the page names are using the the URLs. If you do have case sensitivity issues when first running your applications on Mono with linux then you can use Mono IOMap to get things up and running. IOMap deals with case insensitivity but it does give your application a performance hit so it is not recommended for use in a production environment.

9) Do you have any recommendations, tutorials, blogs, etc? Is there a Stack Exchange site that deals with these types of issues better than this one? (I couldn't find one, other than perhaps the Linux one.

I can't think of any better websites for programming and server admin other than stackoverflow and serverfault.

10) Although it is not a necessity for me to do this, I would like to set it up and do it just to have the option in the future but I won't waste my time on it if it is a complete waste. I have both a linux VPS and Windows VPS that I rent right now, so if I did this it would also allow me to have only a Linux remote server (possibly with less hard drive space and ram) so it would potentially save me money. So my final question is, would you recommend doing this if your situation was similar to mine?

I would recommend it but you must be aware that there is a big learning curve to familiarize yourself with the Linux OSes, different database servers and installing/configuring apps to run on the Mono framework. You probably will find that a lot of things are not as intuitive as they are using the MS technologies. You won't be using a GUI deploy and configure your apps on the server as SSH is the best way to interact with Linux servers.

like image 152
startupsmith Avatar answered Oct 11 '22 17:10

startupsmith