I want to embed a link to a controller action in my page so I can use it from javascript. Something like
var pollAction = '/Mycontroller/CheckStatus'
Now I am happy to hardcode it, but it would be really nice if there were a method I could use to create the URL. The AjaxHelper/HtmlExtensions contain methods to create hyperlinks (.ActionLink(...) and so on), but if you look into the guts of them, they rely on a method called UrlHelper.GenerateUrl() to resolve a controller and action into a url. This is internal so I can't really get at this.
Anyone found a good method in the framework to do this? Or must I roll my own?
Have you tried something along these lines?
var pollAction = '<%=Url.Action("CheckStatus", "MyController") %>';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With