2

Since MVC version 4 it is not required to write src="@Url.Content("~...")". Razor understands tilde and we can simply write src="~...".

I mistakenly though Razor calls UrlHelper.Content() behind the scenes where instance comes from WebViewPage.Url property.

Unfortunately Razor behaves elsewise: Content() method is not get called.

As I substitute default pages' UrlHelper with my own implementation, the results of calling Content() and simply writing url with tilde differ. Therefore I need consistency.

How to override Razor's behavior for tilde?

Community
  • 1
  • 1
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137

0 Answers0