简体   繁体   中英

Mono 3.2.7 MVC5 C# trouble

Web application powered on c# mvc4 .net4.5 from visual studio 2012.

Application deployed in: ubuntu server 13.10. mono version 3.2.7 (I build it from git) web server Apache/2.4.6 mod_mono 2.11 (from git)

Version Information: 3.2.7 (master/5b65cb8 Wed Nov 27 14:49:11 MSK 2013); ASP.NET Version: 4.0.30319.17020

The application is working. But when i try to go to the any form, the application fails with the following error ^

Application Exception System.MissingMethodException Method not found: 'System.Web.Routing.RouteCollection.get_AppendTrailingSlash'.

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc.

How can I resolve it problem?

It is very likely that this means that the property System.Web.Routing.RouteCollection.AppendTrailingSlash has not yet been implemented in Mono.

To avoid these problems in the future, instead of just compiling the application and copying the binaries over to Linux, you should try to compile in Linux instead.

PS: Mono's Compatibility page doesn't list MVC4 as 100% completed, so I would recommend to downgrade to MVC3 to get this working in Linux.

PS II: If you really really cannot downgrade, you may want to help on the task of bringing MVC5 compatibility to Mono; it's actually closer to being real than you think because somebody added a pull request which is going to be reviewed soon: https://github.com/mono/mono/pull/888 (if you test mono with this pull request, and it works for your MVC5 site, I recommend that you say so in a comment inside the pull request, which may make things move forward a bit quicker).

Instead of using ASP.NET MVC helpers, We can use basic HTML syntax like this:

For anchor like components:

 <a href="~/ControllerName/ActionName"> Test </a> 

For form like components:

  <form action="~/ControllerName/ActionName"> <br> <input type="text" placeholder="Enter name"/> <br> <input type="submit" value="Submit"/> </form> 

Surely, it doesn't solve the bug but at least it can get ASP.NET MVC 5 project running on Mono.

Thanks to @teovankot for pointing this out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM