本文整理汇总了C#中Album.findById方法的典型用法代码示例。如果您正苦于以下问题:C# Album.findById方法的具体用法?C# Album.findById怎么用?C# Album.findById使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Album
的用法示例。
在下文中一共展示了Album.findById方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page_Init
protected void Page_Init(object sender, EventArgs e)
{
// -- OUR CODE
// Cookie reading
DataTable cartTable = new DataTable();
cartTable.Columns.Add("Albums", typeof(string));
XmlDocument xmldoc2 = new XmlDocument();
foreach (string cookieName in Request.Cookies.AllKeys)
{
HttpCookie cookie = Request.Cookies[cookieName];
if (cookie.Name.Contains("cart_"))
{
int amount = int.Parse(cookie["amount"]);
Album album = new Album();
album = album.findById(int.Parse(cookie["id"]), Server);
DataRow dtrow = cartTable.NewRow();
dtrow["Albums"] = album.Artist + " - " + album.Title + " (" + amount + " x " + album.Price + " kr.)";
cartTable.Rows.Add(dtrow);
}
}
GridViewCart.DataSource = cartTable;
GridViewCart.DataBind();
// -- OUR CODE END
// The code below helps to protect against XSRF attacks
var requestCookie = Request.Cookies[AntiXsrfTokenKey];
Guid requestCookieGuidValue;
if (requestCookie != null && Guid.TryParse(requestCookie.Value, out requestCookieGuidValue))
{
// Use the Anti-XSRF token from the cookie
_antiXsrfTokenValue = requestCookie.Value;
Page.ViewStateUserKey = _antiXsrfTokenValue;
}
else
{
// Generate a new Anti-XSRF token and save to the cookie
_antiXsrfTokenValue = Guid.NewGuid().ToString("N");
Page.ViewStateUserKey = _antiXsrfTokenValue;
var responseCookie = new HttpCookie(AntiXsrfTokenKey)
{
HttpOnly = true,
Value = _antiXsrfTokenValue
};
if (FormsAuthentication.RequireSSL && Request.IsSecureConnection)
{
responseCookie.Secure = true;
}
Response.Cookies.Set(responseCookie);
}
Page.PreLoad += master_Page_PreLoad;
}