Кажется, здесь возникает состояние гонки
Код: Выделить всё
LogErr("set AppAgent start");
_AppWebsite = db.Websites.Where(x => x.Domain == Request.Url.Host).SingleOrDefault();
LogErr("set AppAgent end");
зависание/гонку легко обнаружить после новой публикации. Если я делаю несколько запросов во время запуска сайта, он обычно зависает. Вероятно, это произошло бы и в другое время, но я не могу выполнить эти запросы достаточно быстро, чтобы вызвать зависание после его запуска.
Уничтожение AppPool устранит зависание.
Вот контроллер. Это базовый контроллер, от которого я взялся. Конечно, я удалил много кода.
Надеюсь, кто-нибудь скажет мне, что я здесь делаю не так.
Код: Выделить всё
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Threading;
using System.Net;
using System.Web;
using System.Web.Mvc;
using System.Security.Claims;
using System.Globalization;
using PropertyDB;
using PropertyDB.Models;
using PropertyDB.Support;
using PropertySite.Models;
using PropertySite.Support;
using System.IO;
namespace PropertySite.Controllers
{
public class BaseController : Controller
{
protected DataContext db = new PropertyDB.DataContext();
protected PageModel DefaultPageModel;
private Website _AppWebsite; //cache for AppAgent
public Website AppWebsite
{
get
{
if (_AppWebsite == null)
{
LogErr("set AppAgent start");
_AppWebsite = db.Websites.Where(x => x.Domain == Request.Url.Host).SingleOrDefault();
LogErr("set AppAgent end");
}
return _AppWebsite;
}
}
public BaseController()
{
}
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
//init model for page
string RequestPath = Request.Path;
DefaultPageModel = new PageModel()
{
Website = AppWebsite,
Route = RequestPath.Substring(1).Split('/'),
};
string PagePath = DefaultPageModel.Route[0];
DefaultPageModel.Page = db.Pages.Where(x => x.WebsiteId == AppWebsite.Id).Where(x => x.Path == PagePath).SingleOrDefault();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (db != null)
{
db.Dispose();
db = null;
}
}
base.Dispose(disposing);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... controller
Мобильная версия