The Name 'Media' Does Not Exist in The Current Context

The name 'media' does not exist in the current context

The @ is a reserved character in Razor. But you can escape it using @@:

@@media print

How can I specify CSS @media within a razor file?

You can use @@ which razor ignores and prints one @.

PDFReactor .NET - @page is not exist is current context

Sorry guys.

I found the answer in this post :
"The name 'media' does not exist in the current context"

Basically it's due to the '@' symbol is actually a reserved character in Razor and we could escape it by using '@@'

Razor View throwing The name 'model' does not exist in the current context

I think you have messed up the web.config file which lives in the Views folder.

Create a new project targeting the same .NET framework and copy its Views/web.config file on top of the one in your current project. This will fix your problem.

Also, as Dudeman3000 commented, if you have Areas in your MVC project they all have Views\web.config files too.

The name 'x' does not exist in the current context

ok, I figured it out. it's an Intellisense problem... in fact, in I just compile the code and run the application, everything is fine. I pulled a lot of hair over this!

@media rule in style tag in .cshtml file throws error

In .cshtml you can not use it as it is because it will be treated as a class or object. you need to put an extra @ whenever you need to add anything that starts with @ in an html file. Try using this

<style type="text/css">
.on-the-fly-behavior {
background-image: url('particular_ad.png');
}
@@media (max-width: 300px) {
.on-the-fly-behavior {
background-image: url('particular_ad_small.png');
}
}
</style>

C# Razor The name does not exist in the current context

In Razor when we want to write c# statements we have to tell it that from here c# code starts:

@{   // from here c# block starts
string testVar = "test";

} // here ends

Now if you want to access this variable in html you can do like this:

<span>@testVar</span>

When you are writing:

string prop = @p.Name + " (" + @p.PropertyType + ") - " + @p.GetValue(@page, null).ToString() + "\r\n";

it is considered as plain text and will be rendered on browser like "string prop = ..."
you have to tell that it is c# code by following way:

@{
string prop = @p.Name + " (" + @p.PropertyType + ") - " + @p.GetValue(@page, null).ToString() + "\r\n";
}

Namespace System.Media does not exit

System.Media namespace is not available in UWP applications so you can't use SoundPlayer. For playing sounds or other media you can use MediaElement



Related Topics



Leave a reply



Submit