my web site name is "nezamerafsanjan" and i writ it with asp.net mvc 4
look at this picutre:
88%CPU
my code in Home Page :
public ActionResult Index()
{
HttpCookie username = Request.Cookies["nezamcookie"];
if (username != null && User.Identity.IsAuthenticated == false)
{
string us = username.Values["UserName"].ToString();
string ps = username.Values["Password"].ToString();
WebSecurity.Login(us, ps, persistCookie: true);
}
var Query = _db.News.Take(30);
var model = (from r in Query.AsEnumerable()
orderby r.CreateDate descending
select new NewsHomeViewModel
{
Id = r.Id,
ImageUrl = r.ImageUrl,
Summary = r.Summary,
Title = r.Title,
UpdateDate = ((persian.GetYear(r.UpdateDate) + "/" + persian.GetMonth(r.UpdateDate) + "/" + persian.GetDayOfMonth(r.UpdateDate)))
}).Take(6);
var modelSpecial = (from r in Query.AsEnumerable()
orderby r.CreateDate descending
where r.Special == true
select new NewsHomeViewModel
{
Id = r.Id,
ImageUrl = r.ImageUrl,
Summary = r.Summary,
Title = r.Title,
UpdateDate = ((persian.GetYear(r.UpdateDate) + "/" + persian.GetMonth(r.UpdateDate) + "/" + persian.GetDayOfMonth(r.UpdateDate)))
}).Take(12);
var modelEducation = (from r in Query.AsEnumerable()
orderby r.CreateDate descending
where r.Education == true
select new NewsHomeViewModel
{
Id = r.Id,
ImageUrl = r.ImageUrl,
Summary = r.Summary,
Title = r.Title,
UpdateDate = ((persian.GetYear(r.UpdateDate) + "/" + persian.GetMonth(r.UpdateDate) + "/" + persian.GetDayOfMonth(r.UpdateDate)))
}).Take(6);
ViewBag.model = model;
ViewBag.NewsViewModelSpecial = modelSpecial;
ViewBag.modelEducation = modelEducation;
return View();
}
my code is news page:
[OutputCache(Duration=360,VaryByHeader="X-Requested-With",Location= OutputCacheLocation.Server)]
public ActionResult Index(int page = 1)
{
var model = (from r in db.News.AsEnumerable()
orderby r.CreateDate descending
select new NewsViewModel
{
Body = r.Body,
Comments = r.Comments,
Education = r.Education,
Financial = r.Financial,
Id = r.Id,
ImageUrl = r.ImageUrl,
Notic = r.Notic,
Public = r.Public,
Refahi = r.Refahi,
Special = r.Special,
Summary = r.Summary,
Title = r.Title,
Visitors = r.Visitors,
CreateDate = ((persian.GetYear(r.CreateDate) + "/" + persian.GetMonth(r.CreateDate) + "/" + persian.GetDayOfMonth(r.CreateDate))),
UpdateDate = ((persian.GetYear(r.UpdateDate) + "/" + persian.GetMonth(r.UpdateDate) + "/" + persian.GetDayOfMonth(r.UpdateDate)))
}).ToPagedList(page,6);
ViewData["News"] = model;
if (Request.IsAjaxRequest())
{
return PartialView("_PartialNews", ViewData["News"]);
}
return View();
}
i dont know why this application give a lot of CPU and Memory when i upload it on my Host?