jajdoo
jajdoo

Reputation: 516

the name 'Url' does not exist in the current context error in Razor webpage

I am trying to do the following in my .cshtml webpage :

    @Url.Content("~/")

However, I get the aforementioned error.

The only lead i have is the following: I created a new project to test out what was wrong - in it, @Url worked fine, so i followed it up (f12). it led to WebViewPage. many other attributes contained in this class were not available (ViewBag etc..), so I'm guessing somewhere along the line i broke some config.

Upvotes: 1

Views: 7389

Answers (1)

luciocamilo
luciocamilo

Reputation: 80

I had the same error and I had the <pages pageBaseType="System.Web.Mvc.WebViewPage"> properly seated, and what solved my problem was

  1. Close Visual Studio
  2. Delete Temporary Files from here

C:\Windows\Microsoft.Net\Framework\{Framework Version}\Temporary ASP.NET Files

  1. Start VS, Right-click your project and click clean-project and re-build.

Upvotes: 4

Related Questions