Hosting or deploying existing ASP.Net Web Application on Linux

 

原文:點擊打開鏈接

 

The very line written above brings anxiety & confusion on our faces. When we again try to give it a deep thought, we find ourselves surrounded with a few questions like: Is it possible at all?, If yes, then how? 

But the most important question that strike our mind is and should be “Why would one want to deploy an existing asp.net application to Linux server?”. Let us begin reading below and try to find out the answers to all these questions.

Few days ago, I was in an informal discussion with one of my client. He just told me that he is having an ASP.Net Web Application which is using Oracle as a database which is installed on Linux Server. The application is working perfectly fine but the application is used by internal users within and outside the organization. He has to pay a windows server license fee which was his primary problem. He just said I wish I had the application developed in Java or any other language that do not requires heavy license fee or I could have been able to deploy it on the Linux Server. The last few words stuck my mind. I kept thinking if there can be any feasible solution to the above problem.

Till now, I hope you would have got the answer of one of the questions, that is, “Why would one want to deploy an existing asp.net application to Linux server?” Let’s proceed further and find answers of the remaining questions.

I didn’t say much to him at that point but I asked him for some time to know the feasibility of any such idea. My search started with crawling on Google where after crawling a couple of links, I came across an article which referred to a tool named “Grasshopper”. By then I had got the direction and the only thing remained was to explore the tool and get it working according to my client’s requirements.

Here lies the answer to yet another question, that is, “Is it possible at all?” and the answer was “Yes”. Now the only question that remained unanswered was “If yes, then How?”. The rest of the article tries to answer this most important question.

What is GrassHopper?

Mainsoft and the Mono Project have joined forces to enable .NET developers to extend their application deployment to Linux environments. The product, called Grasshopper allows ASP.NET, ASMX Web Services, and other server based applications to be compiled to Java bytecode and executed in a J2EE server running on Linux.

GrassHopper is a Visual Studio-based SDK and patented .NET to Java converter that enables you to run .NET Web and server applications to run on Linux® and other Java-enabled platforms.

Mainsoft has done quite a bit of work to ease the process of allowing developers to deploy applications in both environments including creating an installation package that will allow you to run Linux inside Windows using a virtual machine running Debian GNU/Linux. The installation also includes the PostgreSQL database and Apache Tomcat web server.

How to install GrassHopper?

 

Step 1: Go to the website http://dev.mainsoft.com/ and register yourself on the website.

Step 2: Click on “Download GrassHopper” link to download the tool. On the download page, it will ask to accept the terms and conditions of the licence agreement. Check the checkbox and click on download. Also there is a link to download the activation key. Click on that link to download the activation key. You have to fill up a form asking for your details and then you will get the licence key. Store this file on your computer. You will need to provide this file once while creating application in visual studio to activate the grasshopper tool.

Step 3: Double click on the setup and click next.

Step 4: Select on “I accept the terms in the License Agreement and click next”

Step 5: Select the folder to install Grasshopper and click next:

Step 6: Enter any of the available ports and click next.

 

Step 7: Click on install

Step 8: Click on next:

Step 9: Click on "Finish".

Now, the installation of Grasshopper is complete. Now go to Start-> All Programs -> Mainsoft for Java EE 2.5 and start the Tomcat Server.

 

How to use Grasshopper?

 

By now, you have installed Grasshopper and have started the Tomcat server. Now, when the set up is ready let us proceed to attain our primary goal. But before that, we have to ask ourselves a very important question. Is the existing .Net project that we are trying to deploy on Linux server a Web Application or a Web Site?  (In case you have any confusion between a Web Application and a Web site, I would suggest you to please google it and then proceed further). In case it is a Web Application, skip the next step.


How to convert Web Site to Web Application?


Step 1: Open your website in Visual Studio.
Step 2: Right click solution of your website in solution explorer and click on “Add new project”
Step 3: Click on “ASP.Net Web Application” Template and click ok.
Step 4: Copy all the existing items from ASP.Net Web site to ASP.Net Web Application.
Step 5: Right click on ASP.Net Web Application and Click on Convert to Web Application

Now, you will see that your Web Site would have been converted to Web Application. Now, we proceed to next step that is to use the tool and convert the web application to application to WAR file.

Converting Web Application to WAR File

 

Step 1: Set Target Framework to .Net 2.0
(Note: This is a restriction to this tool that it can only convert applications created with framework 2.0 or earlier.)
Right click web application in solution explorer and click on “Properties” and set target framework as 2.0

Step 2: Right click web application in solution explorer and click Generate Java EE Project

Step 3: Click on Next when the wizard pops up.

Step 4: In case there is any reference that is not available in .Net Framework 2.0 and has been left in your project, you get to see this window. Just Cancel the Wizard and Go to “References” in your Web Application. Remove the conflicting References and repeat the steps till the last step and then click Next.

Step 5:  Select the installed Tomcat Server

Step 6: Check “Save a copy of original solution file” and click “Finish”.

Step 7: Browse the downloaded license file and click ok.

You will see the new project generated in your solution explorer prefixed with the name of your Web Application. Step 8: Set this new project as the Startup Project and click on Build.
Your Application will start in the Web Browser.

Next step is to get the resultant WAR File to deploy it on Linux Apache Tomcat Server.

Retrieve WAR File of the Converted Web Application

Go to “%Installed Directory%/Mainsoft for Java EE 2.5/jakarta-tomcat/webapps/” and there you will see the WAR file with the name of your Web Application. You can use this WAR file to deploy the application on Linux Apache Tomcat Server.

Conclusion

The above mentioned steps were the answer for the question “If yes, then How?” So all our questions that initially came in our mind are now answered. But after performing them all, a new set of questions arises in our mind and most important of them being “Will there be any compatibility issues?” and “Will it affect the performance in any way?

Even though the tool helped me a lot in satisfying needs of my client, it is new to me too, so I don’t have precise answers to any of the following questions but on the basis of my observations of project that I converted using the very tool, I have few points that might help you in some way to decide whether or not to go for the tool.

Pros
•    No need of any expensive licensed Windows Server to deploy your web application
•    You have a completely platform independent code compatible with any platform
•    Support for almost all features of .Net Framework

Cons
•    Requires comparatively more hardware on Linux than it demands on Windows.
•    Performance is a little bit slow as compared to Windows Server though the effect is negligible in small and medium sized applications but is noticeable when large sized applications are deployed.
•    Does not support direct conversion from Web Site model.
•    The tool is still under development.
•    Not much support or documentation available.

Now I leave it up to you to explore more on this area from internet and from “http://dev.mainsoft.com/” and decide whether to go for it or not.

發佈了110 篇原創文章 · 獲贊 5 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章