Razor.Templating.Core icon indicating copy to clipboard operation
Razor.Templating.Core copied to clipboard

Issue with UrlHelper

Open cadilhac opened this issue 2 years ago • 3 comments

Hi,

I try to generate a link inside a template, using:

@Url.RouteUrl(<routename>)

RouteUrl returns null.

Thanks

cadilhac avatar Apr 21 '22 18:04 cadilhac

Hi, Please assist with more info:

.NET Version: Project Type: Razor.Templating.Core Version: Expected Output: Sample repo to reproduce(if possible):

soundaranbu avatar Apr 28 '22 05:04 soundaranbu

Hi @cadilhac, I had a look. @Url.RouteUrl will work only in MVC app as it requires the routing features which is not supported by the library. A quick workaround is to call @Url.RouteUrl from the controller action method & then pass it to the ViewModel. Hope it helps. Thanks.

soundaranbu avatar May 08 '22 16:05 soundaranbu

Yes. Sorry, I had not been able to create a repro yet. And yes, I'm using MVC and was already creating the link in the controller as a workaround. Sad that you can't solve it. Cheers.

cadilhac avatar May 09 '22 18:05 cadilhac

I've updated the documentation that UrlHelper is not supported. Hence closing. Please feel to reopen if there are any suggestions. Thanks :)

soundaranbu avatar Jan 28 '23 11:01 soundaranbu