Home .NET ASP.NET MVC 3 server on Synology NAS – solution

ASP.NET MVC 3 server on Synology NAS – solution

by admin

ASP.NET MVC 3 server on Synology NAS - solution
Having had a great drive from Synology for quite some time, I was sad to see that it didn’t host .NET applications. So, armed with the Math in the article habrahabr.ru/post/121159 I’ve set my mind on creating a home server for ASP.NET MVC projects. The mono package there is pretty old, and the classic command sequence to build it did not lead to success. The information was collected from various sources, including habra, bit by bit, giving me an understanding of what to do and in what sequence. Passage of this quest I just want to describe in this article. I hope someone will find it useful.
Bottom line, given :
1. Hardware : NAS Synology 110j with a Marvell mv5281 processor on board.
2. DSM 4.0 operating system (based on a little-used Linux distribution)
Necessary : Install the latest version of mono + xsp.

Preparing

Synology didn’t bother to provide options to install additional packages the traditional way on *nix systems, i.e. through the console. Therefore you need to start by reading the topic www.synology-forum.ru/index.php?showtopic=38 , and perform the necessary gestures. The end result will be to install and run the ipkg console package manager. I cannot give a synopsis in this article since Synology drives come in different processors and the recipe will be different for each architecture.

MONO assembly and installation

After ipkg package manager works, get and unpack latest mono sources (at that time it was 2.10.9). In the process of describing, if necessary, install all needed packages with ipkg by yourself. Because of specific hardware I cannot completely virtualize environment for pure experiment and many packages were installed while "dancing with diamonds" and I even forgot what to install additionally.

wget http://download.mono-project.com/sources/mono/mono-2.10.9.tar.bz2tar -xvf mono-2.10.9.tar.bz2

Mono assembly process:

cd mono-2.10.9./configure --prefix=/usr --sysconfdir=/etc/mono

should be fine, if anything goes wrong look in config.log. It will probably be necessary to deliver some packages.
As a reminder, just my make command failed to compile. You need to add the flags ‘-Wl, -lpthread, -lrt’. But this was not enough. When linking with the pthread library the latter was missing some functions. May be it’s architecture related and I’ll be fine on Intel` devices. Nevertheless, on my ARM, just before compiling, I additionally had to do the following incantations :

mkdir /opt/arm-none-linux-gnueabi/lib_disabledmv /opt/arm-none-linux-gnueabi/lib/libpthread* /opt/arm-none-linux-gnueabi/lib_disabledcp /lib/libpthread.so.0 /opt/arm-none-linux-gnueabi/lib/cd /opt/arm-none-linux-gnueabi/lib/ln -s libpthread.so.0 libpthread.soln -s libpthread.so.0 libpthread-2.5.so

In /opt/etc/ipkg/cross-feed.conf change to
src/gz cross ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable

ipkg remove perlipkg install perl

The magic with libpthread has been figured out by googling and as is clear from the commands, we are swapping out the library. I don’t know why this happened, but it’s a fact. Reinstalling perl, on the other hand, is something else. My packages were originally installed from an "unstable" branch. It is possible that in your case it will be fine.
So, let’s get our popcorn and compile… the process is not fast and sometimes even interesting.

make CFLAGS+='-Wl, -lpthread, -lrt'

So, if mono compiled successfully, install it with the command

make install

and check

mono --version

should output something like

Mono JIT compiler version 2.10.9 (tarball Sun Apr 15 18:40:39 MSK 2012)Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.comTLS: __threadSIGSEGV: normalNotifications: epollArchitecture: armel, soft-floatDisabled: noneMisc: softdebugLLVM: supported, not enabled.GC: Included Boehm (with typed GC and Parallel Mark)

XSP assembly and verification

The environment is installed, now we need to install XSP, the ASP.NET application server for mono. I realize that "ASP.NET server" for XSP sounds too strong, but let’s not forget what it will run on.
It’s all trivial here…

wget http://download.mono-project.com/sources/xsp/xsp-2.10.tar.bz2tar -xvf xsp-2.10.tar.bz2cd xsp-2.10./configuremake install

check after installation :

cd /src/Mono.WebServer.XSPmono xsp4.exe --applications /:./../../test

should give out

xsp4Listening on address: 0.0.0.0Root directory: /xsp-2.10/src/Mono.WebServer.XSPListening on port: 8080 (non-secure)Hit Return to stop the server.

Start the browser and type in the NAS address and port 8080. Our server should display a test page
ASP.NET MVC 3 server on Synology NAS - solution

Preparing an ASP.NET MVC application

1. Creating an ASP.NET MVC 3 Web Application project
ASP.NET MVC 3 server on Synology NAS - solution
2. I chose Internet Application
ASP.NET MVC 3 server on Synology NAS - solution
3. In the original text let’s make a small correction
ASP.NET MVC 3 server on Synology NAS - solution
4. I have set up publishing via a file system (choose whatever you like configured on your NAS, such as FTP)
ASP.NET MVC 3 server on Synology NAS - solution
5. Run XSP on the folder where we are going to deplocate our application

mono xsp4.exe --applications /:./volume1/web/TestMvcOnSynology

6. Next, you need to include in the project assemblies MVC, so they are deployed with our application, as in MONO they are absent. To do this, in the properties of the connected assemblies set the "Copy locally" property to True. List of builds: System.Web.Helpers, System.Web.Mvc, System.Web.WebPages, add builds System.Web.Razor, System.Web.WebPages.Razor, System.Web.WebPages.Deployment and also set "copy locally" property to true.
7. Also, for familiarization purposes, I "cut" the authorization and all mentions of EntityFramework from the application (that’s a topic for a separate article).
1. Removing reference to EntityFramework, System.Data.Entity
Remove AccountController.cs from the project;
3. we exclude AccountModels.cs from Models;
4. completely exclude the folder Account from views
5. In _Layout.cshtml, delete the section with id=logindisplay
6. Exclude _LogOnPartial.cshtml file from the project
That’s it. You can deploat the application and enjoy the result:
ASP.NET MVC 3 server on Synology NAS - solution

Lastly

1. Given that Microsoft not so long ago opened up the source code of the whole ASP.NET stack, it is probably more correct to attach the MVC package from codeplex` to the application and switch all the references to it and deplug the application in this form.
2. Instead of cutting out authorization, you need to implement your own mechanism without using EntityFramework, but as I pointed out, that’s a separate topic.

You may also like