I've overridden UrlHelper.Content()
method. Now I want my implementation to be used instead of default UrlHelper
class.
How can I configure MVC to tell it which class to inject into WebViewPage.Url
property?
Update 1:
The idea is simple. Bundles support cache busting by adding timestamp query parameter to the url.
I want the same functionality for single resource.
UrlHelper
class allows to override its Content(string)
method.
Consequently it is possible to take resource's timestamp into account when generating final string.
Update 2:
It seems like my premise was wrang. I thout that src="~..." is equivalent to src="@Url.Content("~...")". That is not the case.
I don't have a direct answer to your question but you might just create an extension of the URLHelper class like this:
and then just call this method on the
Url
object like this:You're gonna need to introduce your own
WebViewPage
that is providing its own implementation ofUrlHelper
which will override theContent()
method.First, create the types:
Then register your custom
MyWebPage
in~/Views/Web.Config
: