应用程序状态Global.asax

时间:2016-01-22 12:46:02

标签: c# asp.net asp.net-mvc asp.net-mvc-4

Hy家伙,我试图搞清楚Global.asax文件...我正在学习如何在Visual Studio 2010中编写Web应用程序,现在我有Visual Studio 2013.我无法找到global.asax.cs文件,其中我会编写应用程序启动,会话结束,会话启动conde。

我找到了问题的解决方案,但我仍然遇到此错误。请帮忙

' jquery的'不是有效的脚本名称。该名称必须以' .js'。

结尾
<%@ Application Language="C#" %>
<%@ Import Namespace="System.ComponentModel.DataAnnotations" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Web.DynamicData" %>
<%@ Import Namespace="System.Web.UI" %>



<script Language="C#" RunAt="server">

    void Application_Start(object sender, EventArgs e) 
    {
        //Create application state variables
        Application["TotalApplications"] = 0;
        Application["TotalUserSessions"] = 0;

        //Increment TotalApplications by 1
        Application["TotalUserSessions"] = (int)Application["TotalUserSessions"] + 1;
    }

    void Session_Start(object sender, EventArgs e)
    { 
        //Increment TotalUserSessions by 1
        Application["TotalUserSessions"] = (int)Application["TotalUserSessions"] + 1;
    }

    void Session_End(object sender, EventArgs e)
    { 
        //Decrement TotalUserSessions by 1
        Application["TotalUserSessions"] = (int)Application["TotalUserSessions"] - 1;
    }

</script>

0 个答案:

没有答案