#20156: Fixing that malformed content item display/preview URLs caused exceptions instead of resturning 404.

Work Item: 20156
This commit is contained in:
Lombiq
2014-08-16 13:52:02 +02:00
committed by Zoltán Lehóczky
parent 9550146acc
commit a48ba49e67

View File

@@ -22,8 +22,11 @@ namespace Orchard.Core.Contents.Controllers {
public Localizer T { get; set; }
// /Contents/Item/Display/72
public ActionResult Display(int id) {
var contentItem = _contentManager.Get(id, VersionOptions.Published);
public ActionResult Display(int? id) {
if (id == null)
return HttpNotFound();
var contentItem = _contentManager.Get(id.Value, VersionOptions.Published);
if (contentItem == null)
return HttpNotFound();
@@ -38,13 +41,16 @@ namespace Orchard.Core.Contents.Controllers {
// /Contents/Item/Preview/72
// /Contents/Item/Preview/72?version=5
public ActionResult Preview(int id, int? version) {
public ActionResult Preview(int? id, int? version) {
if (id == null)
return HttpNotFound();
var versionOptions = VersionOptions.Latest;
if (version != null)
versionOptions = VersionOptions.Number((int)version);
var contentItem = _contentManager.Get(id, versionOptions);
var contentItem = _contentManager.Get(id.Value, versionOptions);
if (contentItem == null)
return HttpNotFound();