19396

Developing ASP.NET MVC using MonoDevelop on MAC

Question:

I am developing a web app using ASP.NET MVC 2.0 in MonoDevelop. I have latest Mono 2.10 and MonoDevelop 2.4.2 and I am running them on Mac.

According to mono’s release notes, it should support ASP.NET MVC 2.0. However, I found MonoDevelop’s project templates still only support ASP.NET MVC 1.0. So I had to create MVC project from MonoDevelop and remove system.web.mvc 1.0.0.0 from reference and add system.web.mvc 2.0.0.0 back in. I can write and compile code OK and MonoDevelop does provide intellisense for methods only exist in MVC 2.0 from both C# and aspx file. However, when I trying to run it from MonoDevelop, I had Compilation error complaining ”<%: Html.LabelFor(model => model.Name) %>” as LabelFor method cannot be recognized .

MonoDevelop uses XSP as its testing web server. I am not sure how it configured as I didn’t install it myself. I think it was installed as part of MonoDevelop. My guess is XSP somehow still uses MVC 1.0 but I can't prove it as I couldn’t even find where it is installed.

Could anyone help me out please?

Update: I have been suspecting web.config too. Here are how they look like now: web.config

<configuration> <system.web> <compilation defaultLanguage="C#" debug="true"> <assemblies> <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> </assemblies> </compilation> <customErrors mode="RemoteOnly"> </customErrors> <pages> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> </namespaces> </pages> <authorization> <allow users="*" /> </authorization>

web.config under views

<configuration> <system.web> <httpHandlers> <add path="*" verb="*" type="System.Web.HttpNotFoundHandler" /> </httpHandlers> <pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <controls> <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> </controls> </pages> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <handlers> <remove name="BlockViewHandler" /> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> </system.webServer>

Answer1:

Setting up an ASP.NET project for ASP.NET MVC requires changing and adding a load of settings in web.config. The project template in MD is for ASP.NET MVC 1.0, not ASP.NET MVC 2, so you're probably missing some of the necessary settings, maybe a namespace import.

Answer2:

I have this running with two of my current projects on MacOS X. There were only three steps I needed to make sure were done, they are as follows:

<ul><li>Upgrade the version on all references in both the inner (views) web config and the outter(app) [you've done this].</li> <li>Dereference System.Web.MVC 1.0.0.0 & Reference 2.0.0.0 for the project</li> <li>Ensure you don't have 1.0.0.0 binaries in your bin path, the public key does not change</li> </ul>

Answer3:

I've done a downloadable zip file of a project template for Asp.Net MVC 4 which builds and runs on/in Mono/Xamarin Studio/MonoDevelop on Mac & Linux at <a href="http://www.cafe-encounter.net/p1319/run-asp-net-mvc4-on-mono-monodevelop-on-mac-the-c-template-project" rel="nofollow">http://www.cafe-encounter.net/p1319/run-asp-net-mvc4-on-mono-monodevelop-on-mac-the-c-template-project</a>. I should add that a lot of the issue resolution came from <a href="https://stackoverflow.com/questions/4239645/does-the-razor-view-engine-work-for-mono" rel="nofollow">Does the Razor View Engine work for Mono?</a>

Recommend

  • I've been taught not to place most methods in a general “System” class but where do they go ins
  • Going back from a redirect tag - React Router
  • IllegalArgumentException: the error message does not make sense
  • Copy a file block per block in C
  • Why would I extend java.lang.RuntimeException
  • One Definition Rule: Can corresponding entities have different names?
  • Installing gulp-imagemin on Windows creates well over 10,000 files
  • PlayFramework, how to register a BeanPersistListener?
  • netsh acl setting (need alternative method - registry settings?)
  • how to set variables in a php include file?
  • OSX - always hide certain files
  • Is there some graphical way to create my own configuration file on SonarLint?
  • Compiling dlib on OS X
  • How to generate and display a QR Code in ionic 2
  • How do I configure context broker accept post requests from my remote sensor?
  • Spring Cloud Microservice Architecture Confusion
  • Make VS2015 use angular-cli ng at build time in a .NET project
  • The plugin 'org.apache.maven.plugins:maven-jboss-as-plugin' does not exist or no valid ver
  • Recording logins for password protected directories
  • How can I send an e-mail from a vbs script
  • What is Eclipse's Declaration View used for?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Updated Ionic CLI but shows previous version (Windows)
  • Jquery - Jquery Wysiwyg return html as a string
  • SVN: Merging two branches together
  • Invalid access key error using credentials redeemed from an amazon open id token
  • Circular dependency while pushing http interceptor
  • Is there a mandatory requirement to switch app.yaml?
  • retrieve vertices with no linked edge in arangodb
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • Understanding cpu registers
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • How can I remove ASP.NET Designer.cs files?
  • python draw pie shapes with colour filled
  • Add sale price programmatically to product variations
  • Append folder name and increment by 1 using batch script
  • Is there any way to bind data to data.frame by some index?
  • How can i traverse a binary tree from right to left in java?
  • UserPrincipal.Current returns apppool on IIS