iLemming
iLemming

Reputation: 36166

Custom helper. How to get URI from an action method name and controller

I'm writing my own helper and it needs to get a path as a parameter. I can of course refer to it directly passing a string or using Url.Action(). But what if I want to generate fully qualified URI inside of my helper method using action, controller and route values?

It does look a little bit messy right now

 @Ajax.MyHelper(Url.Content("~/Admin/Administration/DeleteItem?Id=<#= Id #>"))

Upvotes: 0

Views: 268

Answers (1)

SLaks
SLaks

Reputation: 887449

Inside the helper, you can call

new UrlHelper(ajax.ViewContext.RequestContext).Content(...)

Upvotes: 2

Related Questions