通常我创建Web应用程序项目并使用code-behind,但我有一个要求,需要使用code-inline创建一个小型的临时演示应用程序。
我向应用程序添加了一个global.asax文件,但由于某种奇怪的原因,Visual Studio 2008 SP1不允许我编辑脚本标记之间的任何代码,例如添加到事件处理程序中的代码,如Application_Start、Session_Start等。但VS确实允许我在脚本标记之外进行编辑。
这只是一个使用内置Web服务器的简单基于文件的Web应用程序。
有什么想法吗?
这是VS创建的code-inline global.asax:
我向应用程序添加了一个global.asax文件,但由于某种奇怪的原因,Visual Studio 2008 SP1不允许我编辑脚本标记之间的任何代码,例如添加到事件处理程序中的代码,如Application_Start、Session_Start等。但VS确实允许我在脚本标记之外进行编辑。
这只是一个使用内置Web服务器的简单基于文件的Web应用程序。
有什么想法吗?
这是VS创建的code-inline global.asax:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when
// the sessionstate mode
// is set to InProc in the Web.config file.
// If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>