Running ASP.NET applications in Ubuntu using ModMono

ModMono is an Apache module which provides ASP.NET support for Apache web server. We will be using Apache as an alternative for Microsoft’s IIS in Windows.

Part One: Installation

For ModMono to work first you need to install Apache. You can click here for instructions on how to install Apache. If you have already installed Apache, you can skip this step.

After that, install ModMono by executing the following command (single line). This will install ModMono with support for ASP.NET 2.0

sudo apt-get install libapache2-mod-mono mono-apache-server2

After the installation is complete, restart Apache and activate the ModMono module by executing the following commands:

sudo /etc/init.d/apache2 restart

sudo a2enmod mod_mono

Now we have to change the version ASP.NET to 2.0 in the configuration file. Open the config file in Gedit:

gksu gedit /etc/apache2/mods-available/mod_mono.conf

Once the conf file is open in Gedit, put a hash (#) in front of the line “Include /etc/mono-server/mono-server-hosts.conf” and delete the hash in front of “Include /etc/mono-server2/mono-server2-hosts.conf”. Now the two lines should look like this:

#Include /etc/mono-server/mono-server-hosts.conf
Include /etc/mono-server2/mono-server2-hosts.conf

Save the file and close it. Now restart Apache one more time

sudo /etc/init.d/apache2 restart

The installation is now complete.

Part 2: Testing

Now it’s time to test the installation. We are going to create a site called Ubuntu. But first we need to create a configuration file for this site inside the directory “etc/apache2/sites-available/”. To do this, execute the following command:

gksu nautilus /etc/apache2/sites-available/

This will open the directory in Nautilus. Now right-click inside the window and create a new empty file and name it “Ubuntu”. Then open the file using a text editor and paste the following text inside it, save and close.

Alias /Ubuntu “/var/www/Ubuntu”
AddMonoApplications default “/Ubuntu:/var/www/Ubuntu”
<Location /Ubuntu>
SetHandler mono
</Location>

(**Note: The formatting of the double-quotes in the above code have to be changed manually. Just delete all the double quotes and type them back again. Make sure you do this, otherwise it may not work.)

Now inside Nautilus, browse to /var/www/ directory and create a new folder called “Ubuntu”. Inside this folder create a new empty file and name it “index.aspx”. Then open this file using a text editor and type the following line of code in it. (Once again, don’t forget to delete and re-type the double-quotes.)

<% Response.Write(“It works like charm!”); %>

Save the file, close it and close Nautilus too. Then come the final steps where we enable the site and restart Apache one last time:

a2ensite Ubuntu

sudo /etc/init.d/apache2 restart

That’s it! Now open your web browser and point to: http://localhost/Ubuntu/index.aspx

You should see the text “It works like charm!” on the page.

Part 3 (Optional): Disabling a site

In part 2 we created a site called Ubuntu. Before we were able to view the aspx page properly we needed to enable the site in Apache. After we’re done testing there’s no need for the Ubuntu site anymore. Before you remove the files, you need to disable the site first.

Open a new Terminal window and execute the following command:

a2dissite Ubuntu

Now you have to remove the file “Ubuntu” we created in the “etc/apache2/sites-available/” directory:

cd /etc/apache2/sites-available/

sudo rm Ubuntu

Then we have to delete the “Ubuntu” folder inside the “/var/www/” directory (which contains index.aspx file) and restart Apache:

cd /var/www/

sudo rm -rf Ubuntu

sudo /etc/init.d/apache2 restart

Now you can close Terminal. Open your browser, clear cache and point to http://localhost/Ubuntu/index.aspx ; it will no longer work.

Note

Even if you have PHP5 and MySQL installed, installing ModMono won’t affect them. So you will be able to work with your PHP and ASP.NET files at the same time.

References:

Ubuntu Community and SqlServerDotNet. Parts 1 & 2 are mainly based on the information from these two sources, but I’ve added some steps in order to simplify the process even more.

About these ads

81 Responses to Running ASP.NET applications in Ubuntu using ModMono

  1. ridho says:

    cool :)

    iwas try and it work

    thank you so much

    good job

    regards

  2. anomit says:

    Thanks a lot. I was totally lost in the wiki docs and all that stuff till I found this post.

  3. ryan says:

    I followed everything up until “That’s it! Now open your web browser and point to: http://localhost/Ubuntu/index.aspx” As when I click the link I get greeted by 503 Service error Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. Maybe you know what the problem is?

  4. pujung says:

    After typing:
    “sudo apt-get install libapache2-mod-mono mono-apache-server2″ and finish downloading I got this for long time:

    Setting up mono-gmcs (1.9.1+dfsg-4ubuntu2) …
    Setting up mono-apache-server (1.9.1-2) …

    Setting up mono-xsp2-base (1.9.1-2) …
    Setting up mono-apache-server2 (1.9.1-2) …
    * Reloading web server config apache2 [ OK ]
    * Restarting web server apache2 … waiting [ OK ]

    What should I do?

  5. pujung says:

    Hi,
    After starting part 2 (testing), I got this error below:

    ** (nautilus:6503): WARNING **: Unable to add monitor: Operation not supported
    Nautilus-Share-Message: Called “net usershare info” but it failed: ‘net usershare’ returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error No such file or directory
    Please ask your system administrator to enable user sharing.

    — Hash table keys for warning below:
    –> file:///var/www/Ubuntu
    –> file:///etc/apache2/sites-available
    –> file:///var
    –> file:///etc/apache2
    –> file:///var/www
    –> file:///

    (nautilus:6503): Eel-WARNING **: “nautilus-metafile.c: metafiles” hash table still has 6 elements at quit time (keys above)

    (nautilus:6503): Eel-WARNING **: “nautilus-directory.c: directories” hash table still has 6 elements at quit time
    seahorse nautilus module shutdown

    What should I do?

  6. Ray says:

    Works great until I try:

    http://localhost/Ubuntu/index.aspx

    Server Error in ‘/Ubuntu’ Application
    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

    Resource URL: /Ubuntu/index.aspx
    Version information: Mono Version: 2.0.50727.42; ASP.NET Version: 2.0.50727.42

    I was on the CUSP of greatness!

  7. Rob says:

    Unfortunately this seems not to be true on Hardy (8.04). There is no way to have mod_php5 and mod_mono at the same time. Installing the one uninstalls the other.

  8. nass says:

    I’ve only tested this on Intrepid (8.10)

  9. Eliasibe says:

    Every thing worked ok!!
    Thank you!

  10. Perry says:

    Can you help me with this? Been googling for an hour with no luck.

    Using VS2008 I “publish” (precompile) a site and copy it over to an Apache server running mod_mono (2.2). Run site, looks good.

    Make a change, republish, recopy, run, still get old site.

    There seems to be nothing I can do short of restarting Apache to get the new pages served.

    There’s got to be a better way, right?

  11. [...] installing Apache, PHP, MySQL and phpMyAdmin, you can install support for ASP.NET files in Ubuntu. Don’t worry, you will be able to work with php and aspx files on the same Apache [...]

  12. sudath says:

    Works great until I try:

    http://localhost/Ubuntu/index.aspx

    Server Error in ‘/Ubuntu’ Application

    Process has not been started.
    Description: HTTP 500. Error processing request.
    Stack Trace:
    System.InvalidOperationException: Process has not been started.
    at System.Diagnostics.Process.get_ExitCode () [0x00000]
    at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:get_ExitCode ()
    at Microsoft.VisualBasic.VBCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000]
    at Microsoft.VisualBasic.VBCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000]
    at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000]
    at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000]
    at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000]
    at System.Web.Compilation.BuildManager.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000]
    at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000]
    at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (System.String virtualPath, System.Type requiredBaseType) [0x00000]
    at System.Web.UI.PageParser.GetCompiledPageInstance (System.String virtualPath, System.String inputFile, System.Web.HttpContext context) [0x00000]
    at System.Web.UI.PageHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String path) [0x00000]
    at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000]
    at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000]
    at System.Web.HttpApplication+c__Iterator2.MoveNext () [0x00000]
    Version information: Mono Version: 2.0.50727.42; ASP.NET Version: 2.0.50727.42

  13. edpresident says:

    Thanx this tutorial. But a have a question. After installition mod mono, PHP runs? I heard to damage PHP this module on ubuntu 8.04 Hardy? Did you tried?

  14. halit yılmaz says:

    it works fine on ubuntu 9.10 desktop but when i tried it on 9.10 server it says service unavailable.
    what should i do

  15. Tarnutpong says:

    It work! work! on Ubuntu 10.04 LTS. Thank a lot.

  16. junjun says:

    when i try to access the http:\\localhost/Ubuntu/index.aspx it says that ” you have chosen to open index.aspx…… which is a aspx File
    from :http://localhost.. there is a pop up window.

  17. asp.net, c#,javascript…

    [...]Running ASP.NET applications in Ubuntu using ModMono « the ubuntu experiment[...]…

  18. MAFRI says:

    mafri…

    [...]Running ASP.NET applications in Ubuntu using ModMono « the ubuntu experiment[...]…

  19. Auto SEO tool…

    [...]Running ASP.NET applications in Ubuntu using ModMono « the ubuntu experiment[...]…

  20. telmessos says:

    I did everything step by step. When I call index.aspx, it tries to open the file :)

  21. Ashlee says:

    Its such as you read my mind! You appear to know so
    much about this, like you wrote the ebook in it or something.

    I feel that you just could do with a few percent to pressure the message house a
    bit, but instead of that, this is magnificent blog.

    A fantastic read. I will definitely be back.

  22. Hi there to every body, it’s my first pay a visit of this weblog; this blog includes amazing and truly fine material in favor of readers.

  23. This paragraph provides clear idea for the new visitors
    of blogging, that actually how to do running a blog.

  24. predator says:

    Notes: The current error page you are seeing can be replaced by a custom error page by modifying the “defaultRedirect” attribute of the application’s configuration tag to point to a custom error page URL.

    ???????????????????????

  25. predator says:

    Web.Config Configuration File

    configuration>
    system.web

    customErrors mode=Off
    system.web
    configuration

    Web.Config Configuration File

    configuration>

    <customErrors mode=RemoteOnl ydefaultRedirect=mycustompage.htm

    system.web
    configuration

  26. Kermit says:

    Hmm it appears like your site ate my first
    comment (it was super long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog writer but I’m still new to the whole thing. Do you have any tips and hints for first-time blog writers? I’d definitely
    appreciate it.

  27. I’ve been exploring for a little bit for any high quality articles or blog posts in this sort of space . Exploring in Yahoo I ultimately stumbled upon this website. Reading this information So i am satisfied to convey that I have an incredibly excellent uncanny feeling I found out exactly what I needed. I most no doubt will make certain to do not disregard this web site and provides it a glance regularly.

  28. Mehedi says:

    can i host framework version 4.5 by these steps? If not ! Please give me a reference. It’s very urgent for me. Please help me

  29. Howdy! I’m at work surfing around your blog from my new iphone 3gs! Just wanted to say I love reading through your blog and look forward to all your posts! Keep up the great work!

  30. Have you regarded purchasing deer antler velvet dietary supplements not long ago?
    If yes, some understanding in regards to the solution will would
    you great. The advantages of using deer antler velvet are many.
    Recognizing the benefits, pretty much all countries earth vast are investigating and investigating about the options of
    deer antler velvet.

  31. Wonderful work! This is the tytpe of information that are supposed tto bee shared around thhe web.

    Disgrace on the search engines for no longer
    positioning this put up higher! Come on over and seek advice from my
    web site . Thanks =)

  32. ogłoszę otwarcie ze balam sie pożyczek dla zadłużonych
    a w ogólności takich bez bik rozmyślałabym że Indywidualna taka debet owo oszukańcze aliści zaryzykowalam dokladnie przeczytałam umowę natomiast
    w tej chwili śpię bez nerwów albowiem płace o 1000
    zł mniejszą ratę

  33. Valuable info. Lucky me I found your web site by accident, and I’m shocked why this accident did not happened earlier!
    I bookmarked it.

  34. Hi, everything is going perfectly here and ofcourse every one is sharing information,
    that’s truly excellent, keep up writing.

  35. Thank you for another informative website. Where else
    may I am getting that kind of information written in such an ideal manner?

    I’ve a undertaking that I’m simply now working on, and I’ve been at the glance out for such info.

  36. Age is also an important factor related to rapid weight reduction and unexplained.
    s talk nutrition as well as perhaps we should mention certain varieties
    of drugs and what drugs might have a result. No doubt these 7 vegetables will
    help you lose fat effectively as a vegetarian, you need to also include other models
    of plant-based foods to realize both effective weight reduction and excellent
    health.

  37. Otis says:

    If you want to get paid for writing this article is going to teach how to get started. org, the blogging platform of choice for all home business bloggers.

  38. I just like the helpful info you provide for your articles.

    I’ll bookmark your blog and check again here frequently.

    I am fairly sure I will learn a lot of new stuff right here!

    Good luck for the next!

  39. What’s even a lot more remarkable about this gadget is that
    it has a rechargeable Lithium-ion battery which helps make it less difficult for
    you to have it about. On September 20, 2007 Bose released a new version of
    its Bose Sound – Dock line, the Sound – Dock Portable, which
    would have a built in battery. S5 Zone – Player, following the custom, delivers crystal-clear sound
    which is arguably getting at the identical level of quality with other audio gear.

  40. Non-surgical treatment includes orthotics, ultrasound therapy (3 MHz each day for 10-15
    minutes), use of night splints that protect the foot all night by
    wrapping it in a special cushion and lastly, use of
    Nonsteroidal anti-inflammatory drugs (NSAIDs). That would
    certainly be annoying, not to mention unproductive.
    What To try Now – With your plantar injury healing and also pain subsiding, you are probably anxious to get
    back to your normal daily actions, which I hope include a
    great deal of exercise.

  41. Good day! This is my first visit to your blog!

    We are a group of volunteers and starting a new initiative in
    a community in the same niche. Your blog provided us useful information
    to work on. You have done a extraordinary job!

  42. Since chicken coop kits are available and also several distinct
    sizes and shapes you’ll want to think about the reason for your own coop.
    {Depending on the climate as well as the breeds, some hens yield even
    more or perhaps much less eggs|One of the machine’s best features is its motor
    which is thermally protected to prevent overheating|I have known
    a lot of people who have got into a bit of a mess using free designs only to find,
    halfway through construction, that they were incomplete or
    unclear|•

  43. I always spent my half an hour to read this weblog’s articles or reviews every day alomg with a mug
    of coffee.

  44. For example, using fire-resistant materials can earn a hefty
    discount. You want a new roof that visually fits with the
    rest of the home. You deserve to have your home looking its best, so you
    will want to have your roof, gutter and deck cleaned
    by professionals, who do the work to the highest standards, only use
    environmentally sound treatment, and provide the best warranty and lowest prices in the business.

  45. It’s difficult to find well-informed people about this topic,
    however, you sound like you know what you’re talking about!
    Thanks

  46. alfyn.ml says:

    alfyn.ml

    Running ASP.NET applications in Ubuntu using ModMono | the ubuntu experiment

  47. Thank you for the good writeup. It in reality used to be a amusement account it.
    Look complicated to more introduced agreeable from you!
    However, how can we communicate?

  48. www says:

    What’s up i am kavin, its my first occasion to commenting anywhere, when i read this paragraph i thought
    i could also create comment due to this brilliant paragraph.

  49. I do consider all the concepts you’ve introduced in your post.
    They are very convincing and will certainly work. Still, the posts are very short for novices.
    May just you please prolong them a bit from subsequent time?
    Thanks for the post.

  50. Jaclyn says:

    Does your site have a contact page? I’m having a tough time locating it but, I’d like to send you an email.
    I’ve got some ideas for your blog you might be interested in hearing.

    Either way, great website and I look forward to seeing it expand over time.

  51. Tanisha says:

    Hi there to all, it’s genuinely a nice for me to go
    to see this web page, it contains important Information.

  52. Weight: Weight usually doesn’t matter a lot when you’re dying for quality, but the lighter the better if you’re
    on the go. If you would like to find a model at a cheaper
    price, then a refurbished model as low as 30% less.
    For all new & refurbished computer purchases we offer free data transfer from
    your old computer. server enasistem

  53. I comment when I appreciate a post on a website or if I have something to contribute to the
    conversation. Usually it is triggered by the sincerness displayed in the post I looked at.
    And on this post Running ASP.NET applications in Ubuntu using ModMono | the ubuntu experiment.
    I was moved enough to drop a comment ;) I actually do have a couple
    of questions for you if it’s allright. Is it just me or
    do some of these responses come across as if they are written by brain dead
    folks? :-P And, if you are posting on additional social
    sites, I’d like to follow you. Could you list all of your public pages like your linkedin profile, Facebook
    page or twitter feed?

  54. I read this article fully concerning the difference of newest and preceding technologies, it’s
    awesome article.

  55. acid reflux says:

    Greetings! I’ve been reading your site for a while now
    and finally got the courage to go ahead and give you a shout out from Austin Tx!
    Just wanted to say keep up the fantastic job!

  56. Hi, I want to subscribe for this website to obtain latest updates, thus where can i do it please
    assist.

  57. Brenna says:

    Asking questions are really fastidious thing if you are not understanding anything fully, however this
    article provides fastidious understanding even.

  58. Aw, this was an exceptionally good post. Spending some time and
    actual effort to make a very good article… but what can I
    say… I put things off a whole lot and don’t manage to get anything done.

  59. Kiara says:

    Hurrah, that’s what I was searching for, what a information! existing here at this web site, thanks admin of this web page.

  60. Aw, this was an extremely good post. Taking
    the time and actual effort to produce a very good article… but what can I say… I hesitate a whole
    lot and never manage to get nearly anything done.

  61. Sasha says:

    Good write-up. I definitely love this site. Continue the good work!

  62. Inez says:

    Hi there! I could have sworn I’ve been to this website before but after reading through some of the post I realized it’s new to me. Nonetheless, I’m definitely happy I found it and I’ll be bookmarking and checking back often!

  63. Vera says:

    Hurrah! In the end I got a web site from where I know how to actually obtain helpful data regarding my study and knowledge.

  64. Trevor says:

    It’s an remarkable post designed for all the online visitors; they will take benefit from it I am sure.

  65. Lottie says:

    Good post however I was wanting to know if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit more. Cheers!

  66. It’s perfect time to make some plans for the long run and
    it is time to be happy. I’ve learn this publish and if I may just I desire to counsel you few fascinating things
    or advice. Perhaps you could write next articles relating to this article.
    I want to read more things approximately it!

  67. Cortez says:

    Oh my goodness! Impressive article dude! Thanks, However I am experiencing difficulties with your RSS. I don’t understand the reason why I am unable to subscribe to it. Is there anybody else getting the same RSS issues? Anyone that knows the answer can you kindly respond? Thanx!!

  68. I’d like to find out more? I’d care to find out some additional
    information.

  69. Wonderful items from you, man. I have be mindful your stuff previous to and you
    are just extremely wonderful. I really like what you have acquired right here, certainly
    like what you are saying and the way in which wherein you assert it.
    You’re making it entertaining and you continue to care for to stay it smart.

    I can’t wait to learn far more from you. That is really
    a tremendous site.

  70. facebook says:

    My spouse and I stumbled over here different page and thought
    I might check things out. I like what I see so i am just following
    you. Look forward to checking out your web page repeatedly.

  71. If some one wants expert view concerning running a blog afterward i suggest him/her to go to
    see this weblog, Keep up the good work.

  72. Hi, the whole thing is going fine here and ofcourse every one is sharing
    information, that’s genuinely excellent, keep up writing.

  73. Hi to all, the contents existing at this site are truly remarkable for
    people experience, well, keep up the good
    work fellows.

  74. NE says:

    This site certainly has all of the information I needed concerning this subject and didn’t know who to ask.

  75. Simply want to say your article is as astounding. The clarity in your
    post is simply spectacular and i could suppose you are
    a professional in this subject. Well together with your
    permission allow me to snatch your feed to keep up to date with forthcoming post.
    Thank you a million and please continue the enjoyable work.

  76. PJ says:

    Wonderful goods from you, man. I have bear in mind your stuff prior to and you’re just too great. I really like what you have received here, really like what you’re stating and the way through which you are saying it. You are making it enjoyable and you continue to care for to keep it smart. I can not wait to learn far more from you. This is really a terrific site.

  77. BL says:

    I simply couldn’t go away your site prior to suggesting that I really enjoyed the usual info an individual provide to your guests? Is gonna be again continuously in order to check up on new posts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: