??????Щ?????????????????檔??????? C# ???????????????Global.asax ????????????Application_Authenticate ??????????? cookie ?????????form????????????????Application_Start ???????????ó??????????Session_Start ??????????????Application_Error ????????????????????????????????
protected void Application_Start(Object sender?? EventArgs e) {
Application["Title"] = "Builder.com Sample";
}
protected void Session_Start(Object sender?? EventArgs e) {
Session["startValue"] = 0;
}
protected void Application_AuthenticateRequest(Object sender?? EventArgs e) {
// Extract the forms authentication cookie
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if(null == authCookie) {
// There is no authentication cookie.
return;
}
FormsAuthenticationTicket authTicket = null;
try {
authTicket = FormsAuthentication.Decrypt(authCookie.Value);
} catch(Exception ex) {
// Log exception details (omitted for simplicity)
return;
}
if (null == authTicket) {
// Cookie failed to decrypt.
return;
}
// When the ticket was created?? the UserData property was assigned
// a pipe delimited string of role names.
string[2] roles
roles[0] = "One"
roles[1] = "Two"
// Create an Identity object
FormsIdentity id = new FormsIdentity( authTicket );
// This principal will flow throughout the request.
GenericPrincipal principal = new GenericPrincipal(id?? roles);
// Attach the new principal object to the current HttpContext object
Context.User = principal;
}
protected void Application_Error(Object sender?? EventArgs e) {
Response.Write("Error encountered.");
}
????????????????????????ЩGlobal.asax ????е?????????????????????Щ?????????????ó?????????????????з??????е?????????????ó????????????????????????Global ?????
???????
????Global.asax ????? ASP.NET ??ó??????????????????????????????????ó????????????????????????ó??????????????????????????????????????????????????????????ASP.NET ??ó???
????????*.ascx *.asax *.aspx.resx *.asax.resx???????
????sln???????????????????????????????????????????????ν????????????
????.csproj:??????????????ó???????????á??????????????к???????????
????.aspx??Web ????????????????????????HTML?????????????????????????????????Visual Studio ????????????????洢???????????????С?????????.aspx ????д?????
????.aspx.cs??Web ????????????λ?????????????????У?????????????????????????.aspx.cs????
????.cs?? ????????????????????????????
????.asax??Global.asax ?????????? ASP.NET ??ó??????????????????????????????????? ASP.NET ?? HTTP ???????????ó?????????????
????.config??Web.config ?????????????????????????????????????
????.aspx.resx/.resx??????????????????????????ó???????κη??????????????????????д洢????????????±?????????ó?????????????
????.XSD:XML schema?????.??DTD??XDR?????XSD
????.pdb:PDB????????????????????????????????????????????????????y????????????
????.suo:???????????????????н?????????????????????????????δ????????????????????????????á?
????.asmx:asmx ??????? WebService ????????????? XML Web services ?????????
????.vsdisco????????????? ???? XML ?????????????? Web ???????????????????????? (URL)??
????.htc:???HTML??????????????????????????HTC??????.htc????????implement????????
????.ascx ???????????????
????.aspx webform html??????
????.cs ??c#?????)
????.vb ??vb?????)
????.aspx.cs ?????webform??????c#??????????????.cs???????
????.aspx.vb ?????webform??????VB??????????????.vb???????
????web.config ???????
????.xml xml???
????.css ????????