即我有一个控制器动作:
public ActionResult Details(int? id)
{
telemetryClient.TrackEvent("CompanyDetailPage");
if (id == null)
{
return RedirectToAction("Error", "Error", new { Text = "id is not specified" });
}
var company = _companyService.CompanyDetail(id.Value);
if (company == null)
{
return RedirectToAction("Error", "Error", new { Text = "Invalid company id" });
}
// create model here and return to client view
return View(model);
}
现在我想在以下情况下添加通知:
- 用户调用没有 id 的方法
- 用户传递的 id 无效
什么是正确的方法?
添加“CompanyDetailPageNullId”、“CompanyDetailPageInvalidId”等事件(指标)?但是对于 CompanyDetailPageInvalidId 我也需要传递 id 。
添加诸如“CompanyDetailPageError”之类的事件(指标)并传入参数有什么问题?
或者,可能,追踪踪迹?