简体   繁体   中英

Visual Studio - Razor website cannot find C# class file

I have a C# file that contains some code, and I want to refer to it in my Razor HTML page, using the code below:

@{
    var check = new pingDevice();
}

//In the main HTML page:

<button onclick="@check.pingDevice().isConnected()">Ping Devices (See Console)</button>

When I try to, however, I get the following error:

CS0246: The type or namespace name 'pingDevice' could not be found (are you missing a using directive or an assembly reference?)

I have the CS file included in my Bin folder, but I still get the same error.

What am I doing wrong? Should I be using a different method of including code in my Razor project?

This will probably work:

<button onclick="@check.isConnected()">Ping Devices (See Console)</button>

check is a pingDevice, it probably does not have a function pingDevice().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM