I have a pretty simple: global.asax file:
<%@ Application Language="C#" %>
<script runat="server">
static class MyClass
{
static string MyFunction()
{
return("Test ok!");
}
}
</script>
But when I try to call it from a web page....
<% Response.Write(MyClass.MyFunction()); %>
...I get "Compiler Error Message: CS0103: The name 'MyClass' does not exist in the current context".
What am I doing wrong?
(Note: To make things more difficult, I'm calling this code from c# in an .asp page. To preserve links I mapped the aspx to the asp suffix. And that seems to work for regular c# code in my asp page.)
使用以下代码调用函数
<% Response.Write(ASP.Global_asax.MyClass.MyFunction()); %>
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.