Method 'RouteCollection.get_AppendTrailingSlash' not found when using Razor Url helpers in ASP.NET MVC 5 Mono
Asked Answered
M

3

6

I am creating an ASP.NET MVC 5 application in Mono (Ubuntu 14.4, Monodevelop 5.9, Mono JIT compiler version 4.0.1).

I see that some of the razor components are not recognized, eg:

@Url.Action

When I add this

<a title="Notifications" href="@Url.Action("_Listing","Home")"> Home </a>

I get this error:

System.MissingMethodException

Method 'RouteCollection.get_AppendTrailingSlash' not found.

System.Web.Mvc is referenced from the packages. Is there anything else which is required?

Update: I tried these solutions so far:

It seems like it is a known issue but I strongly believe there shall be some hack for this to work. I tried using aspx engine also but no gain.

Meaningful answered 28/5, 2015 at 5:28 Comment(2)
Do you get the same error if you move the @Url.Action into javascript, for example: location.href = '@Url.Action("_Listing", "Home")';Insectivore
Nope, it doesn't work . The same issue.Meaningful
R
1

The latest news afaik is that Miguel rejected my minimal pull request last year but you can see at the bottom of that Pull Request that a couple of others have got builds on github which include this and more.

I can't see anyone's got a pull request accepted for mono mainline. The way forward I can see is if you know/can persuade someone on the Xamarin team to push this.

Or, helping with getting the now-open-sourced .Net code running on mono.

But https://github.com/gentoo/dotnet looks interesting: It has pulled this and some other MVC5 changes.

Reversal answered 1/6, 2015 at 20:18 Comment(1)
The fix for this is currently on Master. They expect it to be in the 4.3 release. Not sure when that is going to be however.Hunks
C
1

As of right now, the only way to get around this is to build and install Mono from source from GitHub.

You can refer to the Xamarin Bugzilla issue: https://bugzilla.xamarin.com/show_bug.cgi?id=16475#c13

But, then, you might end up running into something else.... This doesn't seem to be a high-priority for the Mono guys; rather, the Xamarin/mobile story seems to gain the most attention.

Cthrine answered 30/5, 2015 at 18:54 Comment(1)
Thanks @realistchuckle - I tried that as well. Doesn't seems to be working. I'm trying to make MVC 4 atleast to work using your blog but getting numerous issues.Meaningful
R
1

The latest news afaik is that Miguel rejected my minimal pull request last year but you can see at the bottom of that Pull Request that a couple of others have got builds on github which include this and more.

I can't see anyone's got a pull request accepted for mono mainline. The way forward I can see is if you know/can persuade someone on the Xamarin team to push this.

Or, helping with getting the now-open-sourced .Net code running on mono.

But https://github.com/gentoo/dotnet looks interesting: It has pulled this and some other MVC5 changes.

Reversal answered 1/6, 2015 at 20:18 Comment(1)
The fix for this is currently on Master. They expect it to be in the 4.3 release. Not sure when that is going to be however.Hunks
M
0

The problem now seems to be resolved.

Meanwhile, I had used this simple hack: 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="Test"/>
    <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.

Meaningful answered 31/5, 2015 at 18:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.