65 lines
2.3 KiB
Plaintext
65 lines
2.3 KiB
Plaintext
<%@ Application Language="C#" %>
|
|
<%@ Import Namespace="System.Web.Routing" %>
|
|
<%@ Import Namespace="System.Web.Http" %>
|
|
<%@ Import Namespace="System.Web.Optimization" %>
|
|
<%@ Import Namespace="System.Linq" %>
|
|
<%@ Import Namespace="System.Data" %>
|
|
<%@ Import Namespace="System.Web.Configuration" %>
|
|
<%@ Import Namespace="System.Web.Http.Dispatcher" %>
|
|
|
|
|
|
<script runat="server">
|
|
void Application_Start(object sender, EventArgs e)
|
|
{
|
|
// Code that runs on application startup
|
|
// run static constructor
|
|
System.Runtime.CompilerServices.RuntimeHelpers.RunClassConstructor(typeof(Sites).TypeHandle);
|
|
//註冊webapi
|
|
GlobalConfiguration.Configure(WebApiConfig.Register);
|
|
//GlobalConfiguration.Configuration.Services.Replace(
|
|
// typeof(IHttpControllerSelector),
|
|
// new NamespaceHttpControllerSelector(GlobalConfiguration.Configuration));
|
|
|
|
|
|
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling =
|
|
Newtonsoft.Json.ReferenceLoopHandling.Ignore;
|
|
GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);
|
|
//GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
|
|
//註冊自訂路由
|
|
RouteConfig.RegisterRoutes(RouteTable.Routes);
|
|
//bundle js、css
|
|
//BundleConfig.RegisterBundles(BundleTable.Bundles);
|
|
|
|
|
|
}
|
|
|
|
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.
|
|
|
|
}
|
|
protected void Application_PostAuthorizeRequest()
|
|
{
|
|
System.Web.HttpContext.Current.SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior.Required);
|
|
}
|
|
|
|
</script>
|