Is available on www.github.com/chrisfcarroll/AspNetTemplatesForMono/Mvc4CSharpRazorFx45Intranet. (The github download includes all the required dlls in case you don't have NuGet working, so it's an oversized download. If you do have NuGet working, you'll find everything as NuGet expects).
One step to get the MVC4 template working on Mono
Download from github and open the solution in Xamarin Studio. It should almost work out-of-the-box; the one thing you have to do is either do this from the command line:
sudo mkdir /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry
sudo chmod g+rwx /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry
(replacing 3.2.5
with your mono version, which you get at the command line with mono --version
);
Or, the alternative to this is to delete the reference to Microsoft.Web.Infrastructure.dll
from the project and delete it from the bin directory too.
Small disclaimer: tested on Mac only. If you can offer feedback for Linux/Windows that would be great.
Footnote: How to build the Visual Studio Asp.Net MVC 4 template on Mono
For the interested who have a copy of VS2012, here's the recipe.
- From Visual Studio 2012 create a new Project with the C#-Web-MVC4 Wizard and choose Intranet-Razor-No Unit Test.
- Try to run the resulting project on Mono on Mac.
- Address the problems arising in the following order
-
System.UnauthorizedAccessException
Access to the path "/Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry" is denied. (Where the whole path varies by O/S & 3.2.5
is your mono version).
Resolution
sudo mkdir /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry
sudo chmod g+rwx /Library/Frameworks/Mono.framework/Versions/3.2.5/etc/mono/registry
i.e. allow members of admin group to read/write the registry. Obviously you could widen privileges but this is all that's needed for asp.net.
-
System.TypeLoadException
Could not load type 'System.Data.Entity.Migrations.Sql.SqlCeMigrationSqlGenerator' from assembly 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Resolution
Remove references to Entity framework from THREE places: web.config
, Project references
AND delete them from the bin directory
if they in there:
- System.Data.Entity
- System.Web.Entity
- Entity.Framework
-
System.TypeLoadException
Could not load type 'System.Net.Http.MultipartRelatedStreamProvider' from assembly 'System.Net.Http.Formatting ...
Resolution
add this redirect to the web.config. You should find there are other 'dependentAssembly' redirects in there within the
section so put it alongside them:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
-
And finally ... System.Web.HttpException
Unauthorized.
Because you don't have windows authentication available to you when running on Mac or Linux.
Resolution
Comment out
<deny users="?"></deny>
from the web.config
.
Note that you're now unsecured. The simplest way to add security back in is to use Forms authentication. If you don't know how to do this, the simplest start might to look at http://google.com/search?q=Forms+authentication+user+names+in+web.config
Kudos