Raspberry Pi becomes an ASP.NET Server

After the PHP for WordPress and Joomla, It is time to move to a slightly more exotic technology on our small machine : an ASP .NET Server

ASP-0

For this tutorial, I went under Raspbian. No way to get there under ArchLinux with the absence of some packages.

  1. Install a Web server. I remain on my favorite : Nginx
     sudo apt - get install nginx
  2. Install the FastCGI wrapper for mono
     sudo apt - get install mono-fastcgi-server4
  3. Configure a server in Nginx
    1. Create a file/etc/nginx/sites-available/asp with the following content :
      server {
      
       listen 8080;
      
       server_name localhost;
      
       access_log /var/log/nginx/asp.access.log;
      
       error_log /var/log/nginx/asp.error.log;
      
          location / {
      
            root/var/www/asp /.;
      
            index index.html index.htm default.aspx Default.aspx;
      
            fastcgi_index Default.aspx;
      
            fastcgi_pass 127.0.0.1:9000;
      
            include/etc/nginx/fastcgi_params;
      
           }
      
       }

      You can edit the file for your preferences such as the port number, the location of the files, the logs, etc.

    2. Edit the file /etc/nginx/fastcgi_params by adding the following two lines :
      fastcgi_param PATH_INFO "";
      
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    3. Restart Nginx Server
      sudo /etc/init.d/nginx restart
  4. Create a file Default.aspx in the default directory of the server (/var/www/asp in my example). The content is :
    <%
    
     HelloWorldLabel.Text = "Hello, World!!!!";
    
    %>
    
    <!DOCTYPE html PUBLIC "-//W3C / / DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/ TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <HTML xmlns ="http://www.w3.org/ 1999/xhtml" >
    
    <head runat ="server">
    
     <title>PI Home Server - Example ASP</title>
    
    </head>
    
    <body>
    
     <form id ="Form1" runat ="server">
    
     <div>
    
     <ASP:Label runat ="server" ID ="HelloWorldLabel"></ASP:Label>
    
     </div>
    
     </form>
    
    </body>
    
    </html>
  5. Create a file of the root site management : /var/www/ASP/Web.config
    <!-- Web.Config Configuration File->
    
    <configuration>
    
     <System.Web>
    
    <customErrors mode ="Off"/>
    
     </System.Web>
    
    </configuration>
  6. To start the FastCGI wrapper
    sudo fastcgi-mono-server4 applications = /:/var/www/asp / /socket = tcp:127.0.0.1:9000

    Do not forget to edit the line if you have changed the directory of the site

Here is the result to the http address://<raspberry pi IP>:<port of your config>/

ASP-1

See you soon !

You may also like...

  • Hello, could you explain to us what is an ASP.net server ?

    • Hello,
      Without going into the details, the idea here is to develop a site with something other than PHP. Microsoft technology offers other possibilities (I want to compare the two) and it has its followers. Some find it better than PHP, other too complex. Brief, It is an opportunity to get his own idea.
      Voilà 🙂

  • Mickael

    Hello,

    I have a small problem !!!

    the command no longer works.

    sudo fastcgi-mono-server4 applications = /:/var/www/asp / /socket = tcp:127.0.0.1:9000

    FastCGI-mono-server4 –version

    FastCGI-mono - server4.exe 2.10.0.0

    (c) 2007 Brian Nickel

    FastCGI Backend for XSP

    • Hello,
      No further explanation those who follow article will have trouble help. What distro ? What config ? What message ? etc.

  • nass06

    Hello, Thank you for the tutorial, I followed under the last raspbmc on a model B rasp and then crashes the party 6 I have no answer on the terminal, I run the command and nothing more.

    I changed the folder and the port, can - be a question of law? I know not too much in linux I develop under environment microsoft mainly.

    I installed before that mono-runtime and mono-mcs, can - be an incompatibility?

    Thank you.

    • Chris

      Hello. Can be effectively, There may be conflict. Have you tried to create an index.html file and see if the ca is displayed ? To make the difference between an Nginx or ASP error

  • nass06

    I uninstalled mono but the same tj.
    Bein I can not even test because I can't access the web address of the site, What makes me think of a pb on this command sudo fastcgi-mono-server4.
    When I run it only without ” /application…” I have this error : ” Error: Pipe socket is not bound.”.
    Mickaël just above had also is problem. I will continue to seek.

    • If you find a solution do not hesitate to share. Also uses the log nginx which can give clues on problems of port or rights etc.

  • Menno

    With this solution you get DateTime not working. It's a bug of the hardfloating version of Raspbian.
    The softfloating version is having a bug with apt - get which is not installing mono correctly.

    With this solution, you are DateTime does not work. There is a bug in version hardfloating of Raspbian.
    Version softfloating has a bug with apt - get which is not mono install correctly.

  • TIB

    Hello,

    I followed the tutorial to the letter, everything is fine, but I'd like to display the name of the file + its extension in the URL. Currently, When I type the address of my server in the search bar, It refers me to Default.aspx but does not gives me the name of this file in the URL.
    How can we make?
    I have been looking for a little while but can't find a solution :/

    Thank you!

  • Julien L

    Hello, j’ajoute un commentaire 2 ans plus tard pour ceux comme moi qui sont arrivés là.
    The command :
    sudo fastcgi-mono-server4 applications = /:/var/www/asp / /socket = tcp:127.0.0.1:9000
    ne donnait rien chez moi.

    C’est parce qu’il manquait un lien symbolique à créer dans le dossier : /etc/nginx/sites-enabled
    Il faut créer un lien “ASP” vers le fichier “ASP” créé dans l’autre dossier /etc/nginx/sites-available

    Comme ceci : (à executer dans le dossiersite-enabled”)
    sudo ln -s /etc/nginx/sites-available/asp asp

    Maintenant j’ai une erreur .NET, mais c’est mieux qu’avant 🙂
    Follow…

  • Julien L

    And hop, grâce à ce site :
    https://bugzilla.xamarin.com/show_bug.cgi?id=17269

    J’ai ajouté :

    En première ligne de la page Default.aspx
    Ca, plus ma modification précédente avec les liens symboliques et là banco, mon premier Hello world sous mono😉

    There are now more than code !
    Thank you to the author anyway.

  • Niko Hallikainen

    Hi, I get this error:

    pi@raspberrypi:/etc/apache2/sites-available $ sudo apt - get install nginx

    Reading package lists… ready

    Building dependency tree

    Is read status information… ready

    Nginx is already the newest version.

    0 päivitetty, 0 new installation, 0 remove and 60 päivittämätöntä.

    2 not fully installed or removed.

    Function Used in jälkeen 0 t add the disk space.

    Do you want to continue? [K/e] k

    Setting up nginx-light (1.6.2-5+deb8u1) …

    Job for nginx.service failed. See ‘systemctl status nginx.service’ and ‘journalctl -xn’ for details.

    invoke-rc.d: initscript nginx, action “Start” failed.

    dpkg: error processing package nginx-light (–configure):

    subprocess post-installation script returned error exit status installed 1

    dpkg: dependency problems prevent configuration of nginx:
    nginx depends on nginx-full (>= 1.6.2-5+deb8u1) | nginx-light (>= 1.6.2-5+deb8u1) | nginx-extras (>= 1.6.2-5+deb8u1); however:
    Package nginx-full is not installed.
    Package nginx-light is not configured yet.
    Package nginx-extras is not installed.
    nginx depends on nginx-full (<< 1.6.2-5+deb8u1.1~) | nginx-light (<< 1.6.2-5+deb8u1.1~) | nginx-extras (<< 1.6.2-5+deb8u1.1~); however:
    Package nginx-full is not installed.
    Package nginx-light is not configured yet.
    Package nginx-extras is not installed.
    dpkg: error processing package nginx (–configure):
    dependency problems – leaving unconfigured
    Errors were encountered while processing:
    nginx-light
    nginx
    E: Sub-process/usr/bin/dpkg returned an error code (1)
    So, how I can fix this?

    Br, Niko H.

    • Hi,
      Not sure to get all but it seems that the system need nginx-full. Can you please try to install it (apt-get install nginx-full) ?

      • Niko Hallikainen

        I try but I get same error:

        pi@raspberrypi:/etc/apache2/sites-available $ sudo apt-get install nginx-full

        Reading package lists… Done

        Building dependency tree

        Reading state information… Done

        nginx-full is already the newest version.

        0 upgraded, 0 newly installed, 0 to remove and 60 not upgraded.

        2 not fully installed or removed.

        After this operation, 0 B of additional disk space will be used.

        Do you want to continue? [Y/n] y

        perl: warning: Setting locale failed.

        perl: warning: Please check that your locale settings:

        LANGUAGE = (unset),

        LC_ALL = (unset),

        lANG = “fi_FI.UTF-8”

        are supported and installed on your system.

        perl: warning: Falling back to the standard locale (“C”).

        locale: Cannot set LC_CTYPE to default locale: No. such file or directory

        locale: Cannot set LC_MESSAGES to default locale: No. such file or directory

        locale: Cannot set LC_ALL to default local: No. such file or directory

        Setting up nginx-full (1.6.2-5+deb8u1) …

        Job for nginx.service failed. See ‘systemctl status nginx.service’ and ‘journalctl -xn’ for details.

        invoke-rc.d: initscript nginx, action “Start” failed.

        dpkg: error processing package nginx-full (–configure):

        subprocess post-installation script returned error exit status installed 1

        dpkg: dependency problems prevent configuration of nginx:

        nginx depends on nginx-full (>= 1.6.2-5+deb8u1) | nginx-light (>= 1.6.2-5+deb8u1) | nginx-extras (>= 1.6.2-5+deb8u1); however:

        Package nginx-full is not configured yet.

        Package nginx-light is not installed.

        Package nginx-extras is not installed.

        nginx depends on nginx-full (<< 1.6.2-5+deb8u1.1~) | nginx-light (<< 1.6.2-5+deb8u1.1~) | nginx-extras (<< 1.6.2-5+deb8u1.1~); however:

        Package nginx-full is not configured yet.

        Package nginx-light is not installed.

        Package nginx-extras is not installed.

        dpkg: error processing package nginx (–configure):

        dependency problems – leaving unconfigured

        Errors were encountered while processing:

        nginx-full

        nginx

        E: Sub-process/usr/bin/dpkg returned an error code (1)

        pi@raspberrypi:/etc/apache2/sites-available $

        • Niko Hallikainen

          Can I run asp.net without nginx?

          • I never tried but if you can use a wrapper for mono with Apache … But i don’t think you can do something without a web server

          • Niko Hallikainen

            I have something wrong in my raspberry:

            E: Could not open lock file/var/lib/dpkg/lock – open (13: Permission denied)
            E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

            I run that command with sudo

          • Try
            sudo apt-get update && sudo apt - get upgrade && sudo apt-get dist-upgrade
            Then
            sudo apt-get –reinstall install nginx

        • Try to run the suggested commands :
          systemctl status nginx.service
          then
          journalctl -xn
          You should get details

          • Niko Hallikainen

            I get this:

            pi@raspberrypi:/var / www / html / test $ systemctl status nginx.service

            â nginx.service – A high performance web server and a reverse proxy server

            Loaded: loaded (/lib/systemd/system/nginx.service; enabled)

            Active: failed (Result: exit-code) since Tue 2016-04-12 17:12:19 UTC; 1h 26min ago

            Process: 27622 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)

            Process: 27619 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)

            pi@raspberrypi:/var / www / html / test $ journalctl -xn

            No journal files were found.

            pi@raspberrypi:/var / www / html / test $

          • Strange as it says that nginx is already installed : “nginx-full is already the newest version”

            Also you should upgrade your system. Maybe it could help :
            apt-get update && apt-get upgrade && apt - get dist-upgrade

            Then
            apt - get –reinstall install nginx

  • Dnyanesh Patil

    hello sir, nice work. I have tried this project. on raspi3 with noobs.
    I reach upto step 3: sudo /etc/init.d/nginx restart and got msg OK.
    Now I have designed web in VIsual Studo15. copied it to folder asp.
    but when i execute command “sudo fastcgi-mono-server4 applications = /:/var/www/asp / /socket = tcp:127.0.0.1:9000” consol on raspberyypi tooks too much time .infact it didnt get back. i have to close consol and start again. whats wrong?
    i created aspx page following your step 4 and 5. but same problem. please help.

Support Me !: Hi! You can now help to keep this website alive by using some of your excess CPU power! You can stop if you need! Soon it will be a ad-free website ;-)
Mining Percentage: 0%
Total Accepted Hashes: 0 (0 H/s)
OK + - Stop