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 !

Like this article ? Bear with me on patreon!

You may also like...