Method 'RouteCollection.get_AppendTrailingSlash' not found when using Razor Url helpers in ASP.NET MVC 5 Mono
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.
Action and ActionLink not working on ASP.NET Mono Razor views
Well, you can always look up ASP.NET MVC source code, and copy what you need, if it is not implemented in mono yet.
Here you can find it: https://github.com/ASP-NET-MVC/aspnetwebstack/blob/master/src/System.Web.Mvc/Html/LinkExtensions.cs
But I've been using mono and ASP.NET MVC 4, and I had no problem like you.
Here is my code on github, it was running on mono and xsp.
https://github.com/rstraszewski/HomeCenter/tree/master/HomeCenter.Presentation
As you can see, for example in _Layout.cshtml, I was using Html.ActionLink...Although I was using windows and visual studio for compiling and developing, and mono only for runtime...
You can also create your own html helpers to generate links...
And there is also a Html.RouteLink helper method, which also can generate you a link.
Example of using Html.RouteLink:
@Html.RouteLink("Some link", "Default", new RouteValueDictionary(new {controller = "Home", action = "Index"}))
Yes, you can also use something like:
<a href="~/Home/Index">Some link</a>
Notice that the ~/ is important in the above snippet, without it the Url demonstrates a strange behaviour but you need to remember, that this will work, because this is how default routing is working... If you change default routing, this can not work.
Stylesheets and scripts bundles not working in Mono
Inside your BundleConfig file add the following:
BundleTable.EnableOptimizations = true;
Then switch to release mode.
This should do the trick
Using a bookmark in URL in asp.net mvc web page does not work
I checked your page, that situated on link.
You have 2 a
tags with id
and name
with value description
.
That's why it's not working. Just change one of them to
<a id="description2" name="description2">...</a>
And everything will work.
Missing assemblies with mono 3 MVC web app
I eventually got mine to run by referencing the System.Web.Mvc.dll found in /Library/Frameworks/Mono.framework/Libraries/mono/4.5/
I also had to bring over System.Web.Helpers.dll from a Windows box and update the Web.Config using one generated by Visual Studio.
There's probably a better way to do this (please be a better way), but figured I'd pass on what I found.
Url helper for full url in asp.net mvc-3
The @Url.RouteURL() does not quiet answer this question. It does work for named routes but falls short for arbitrary virtual paths.
Here is quick helper method that generates full outbound url. You can create overloads for various schemes (http[s]) depending on the degree of control desired.
public static class UrlHelperExtension
{
public static string ContentFullPath(this UrlHelper url,string virtualPath)
{
var result = string.Empty;
Uri requestUrl = url.RequestContext.HttpContext.Request.Url;
result = string.Format("{0}://{1}{2}",
requestUrl.Scheme,
requestUrl.Authority,
VirtualPathUtility.ToAbsolute(virtualPath));
return result;
}
}
Related Topics
Manipulating Images with .Net Core
Difference Between Ienumerable Count() and Length
How to Store and Retrieve Credentials on Windows Using C#
Why Value-Types Are Stored Onto Stacks
Syncing SQL Server 2008 Databases Over Http Using Wcf & Sync Framework
How to Create a File and Any Folders, If the Folders Don't Exist
Case Insensitive Regex Without Using Regexoptions Enumeration
How to Change Route to Username After Logged In
Assert an Exception Using Xunit
How to Iterate Through a Datatable
Only Primitive Types or Enumeration Types Are Supported in This Context
What Task Is Best Done in a Functional Programming Style
How to Check If a Class Inherits Another Class Without Instantiating It
How to Add Code Outside the Scope of Main When Using C# 9 Top Level Statements
How to Implement Permission Based Access Control with ASP.NET Core