c# - Action and ActionLink not working on ASP.NET Mono Razor views -
how use hyper linking in razor without @url.*
or @html.*
there 4 ways hyperly link views in asp.net mvc far know:
@url.action
@url.actionlink
@html.action
@html.actionlink
i can use them as, example:
<a href=@url.action("actionname","controllername")> test </a>
which generates:
<a href="controllername/actionname"> test </a>
is there way generate url part i.e. "controllername/actionname" in asp.net mvc razor apart above mentioned 4 ways?
background: mono not able recognize these kind of razor components. if kind of url generation works out can use asp.net mvc 5 razor on mono.
well, can asp.net mvc source code, , copy need, if not implemented in mono yet. here 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 , asp.net mvc 4, , had no problem you. here code on github, running on mono , xsp. https://github.com/rstraszewski/homecenter/tree/master/homecenter.presentation
as can see, example in _layout.cshtml, using html.actionlink...although using windows , visual studio compiling , developing, , mono runtime...
you can create own html helpers generate links... , there html.routelink helper method, can generate link.
example of using html.routelink:
@html.routelink("some link", "default", new routevaluedictionary(new {controller = "home", action = "index"}))
yes, can use like:
<a href="~/home/index">some link</a>
notice ~/ important in above snippet, without url demonstrates strange behaviour need remember, work, because how default routing working... if change default routing, can not work.
Comments
Post a Comment