我的自定义模块刚刚开始出现一个非常奇怪的问题,直到昨晚才开始发生。基本上,当我尝试请求为模块创建的自定义视图时,前几个页面显示正常,然后突然间其余的内容项页面超时,直到我回收应用程序池。(在浏览器中我收到 324 no data sent 错误)。在 App_Data 文件夹下的错误日志中,我也没有收到与此事件有关的错误。
这是我在事件查看器中收到的错误:
3005
An unhandled exception has occurred.
12/31/2012 12:03:17 PM
12/31/2012 5:03:17 PM
59d62d1f2da347caafd2dee71266126f
43
1
0
/LM/W3SVC/10/ROOT-2-130014459492939950
Full
/
E:\Inetpub\Test-Website\
SERVERNAME
24756
w3wp.exe
NT AUTHORITY\NETWORK SERVICE
TimeoutException
Transaction Timeout
(the url was displayed here)
admin
True
Forms
NT AUTHORITY\NETWORK SERVICE
39
NT AUTHORITY\NETWORK SERVICE
False
我的开发计算机上没有这个问题(在 iis 或 Visual Studio 上运行网站不会重现问题)。
我几乎肯定该模块的设置是为了有效地处理每个连接。另外,考虑到自从网站上线(现在大约一个月)以来还没有发生这种情况,我猜这与代码无关。
这是我如何设置服务类的示例:
namespace Example.Services
{
public interface IDocumentNoteService : ITransientDependency
{
List<DocumentNoteRecord> GetNotes(int? packageId, int noteTypeId);
}
public class DocumentNoteService : IDocumentNoteService
{
private readonly IRepository<DocumentNoteRecord> _docNoteRepo;
public DocumentNoteService(IRepository<DocumentNoteRecord> docNoteRepo)
{
_docNoteRepo = docNoteRepo;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
public ILogger Logger { get; set; }
public Localizer T { get; set; }
public List<DocumentNoteRecord> GetNotes(int? packageId, int noteTypeId)
{
try {
var Notes = _docNoteRepo.Table.Where(x => x.Package_Id == packageId).Where(x => x.Note_Type_Id == noteTypeId).ToList();
_docNoteRepo.Flush();
return Notes;
}
catch (Exception ex) {
Logger.Error(ex, "There was a problem getting the document notes for this tour.");
}
return Enumerable.Empty<DocumentNoteRecord>().ToList<DocumentNoteRecord>();
}
}
}
这是零件驱动程序的代码:
namespace ExampleCode.Drivers
{
public class TourPartDriver : ContentPartDriver<TourPart> {
private readonly ITourPartService _tourPartService;
private readonly ITourDateService _tourDateService;
private readonly IItinDetailService _tourItinDetailsService;
private readonly IExperiencesService _tourExpService;
private readonly ITourOptionService _tourOptionService;
private readonly IDestinationFactService _destinationFactService;
private readonly IDestinationFactManager _destinationFactManager;
private readonly IDocumentNoteService _documentNoteService;
private readonly IPackageUpgradesService _packageUpgradesService;
public TourPartDriver(
ITourPartService tourService,
ITourDateService tourDateService,
IItinDetailService tourItinDetailsService,
IExperiencesService tourExpService,
ITourOptionService tourOptionService,
IDestinationFactService destinationFactService,
IDestinationFactManager destinationFactManager,
IDocumentNoteService documentNoteService,
IPackageUpgradesService packageUpgradesService
) {
_tourPartService = tourService;
_tourDateService = tourDateService;
_tourItinDetailsService = tourItinDetailsService;
_tourExpService = tourExpService;
_tourOptionService = tourOptionService;
_destinationFactService = destinationFactService;
_destinationFactManager = destinationFactManager;
_documentNoteService = documentNoteService;
_packageUpgradesService = packageUpgradesService;
Logger = NullLogger.Instance;
T = NullLocalizer.Instance;
}
public ILogger Logger { get; set; }
public Localizer T { get; set; }
protected override DriverResult Display(
TourPart part, string displayType, dynamic shapeHelper) {
return ContentShape("Parts_Tour", () => shapeHelper.Parts_Tour(
TourID: part.tour_id,
TourName: part.tour_name,
PackageID: part.package_id,
Highlights: _tourExpService.GetTourExperiences(part.tour_id, part.package_id),
Description: part.description,
TourDates: _tourDateService.GetTourDatesDD(part.tour_id),
TourItinDetails: _tourItinDetailsService.GetItinDetails(part.package_id),
InitialTourOffsetDate: _tourDateService.GetInitialTourDateOffset(part.package_id),
TourOptions: _tourOptionService.GetInitialTourOptions(part.package_id),
TourPrice: _tourDateService.GetTourPrice(part.package_id),
TourNumDays: _tourItinDetailsService.GetTourNumDays(part.package_id),
TourNumMeals: _tourDateService.GetTourNumMeals(part.package_id),
DestinationFacts:_destinationFactManager.GetCategoryFacts(part.package_id),
PleaseNote: _documentNoteService.GetNotes(part.package_id, (int)NoteTypes.DocNoteType.PleaseNote),
WebRemarks: _documentNoteService.GetNotes(part.package_id, (int)NoteTypes.DocNoteType.WebRemarks),
Pace: _documentNoteService.GetNotes(part.package_id, (int)NoteTypes.DocNoteType.Pace),
PackageUpgrades: _packageUpgradesService.GetInitialPackageUpgrades(part.package_id)
));
}
}
}
这是视图的代码:
@{
List<DocumentNoteRecord> pleaseNote = Model.PleaseNote;
List<DocumentNoteRecord> webRemarks = Model.WebRemarks;
List<DocumentNoteRecord> pace = Model.Pace;
if (pleaseNote.Count > 0)
{
<h4 class="tourSubTitle1">Please Note</h4>
foreach (var note in pleaseNote) {
<p>@Html.Raw(note.Note)</p>
}
}
if (webRemarks.Count > 0) {
<h4 class="tourSubTitle1">Web Remarks</h4>
foreach (var noteRemark in webRemarks) {
<p>@Html.Raw(noteRemark.Note)</p>
}
}
if (pace.Count > 0)
{
<h4 class="tourSubTitle1">Pace</h4>
foreach (var notePace in pace)
{
<p>@Html.Raw(notePace.Note)</p>
}
}
}
任何帮助将不胜感激!我肯定在这里泡菜。
谢谢。