mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
#20156: Fixing that malformed content item display/preview URLs caused exceptions instead of resturning 404.
Work Item: 20156
This commit is contained in:
@@ -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();
|
||||
|
||||
|
Reference in New Issue
Block a user