#19158: Fixing exception when a code Shape alternate is created

If a Zone alternate is created, it will be empty and it might result int the
site rendering an empty page.

Work Item:

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-10-18 11:43:34 -07:00
parent 8eb360784b
commit 76c203dd14

View File

@@ -6,8 +6,7 @@ using Orchard.Security;
using Orchard.Mvc.Extensions;
using Orchard.Themes;
namespace Orchard.DesignerTools.Controllers
{
namespace Orchard.DesignerTools.Controllers {
[Themed]
public class AlternateController : Controller {
private readonly IWebSiteFolder _webSiteFolder;
@@ -30,9 +29,10 @@ namespace Orchard.DesignerTools.Controllers
var currentTheme = _themeManager.GetRequestTheme(Request.RequestContext);
var alternateFilename = Server.MapPath(Path.Combine(currentTheme.Location, currentTheme.Id, "Views", alternate));
var isCodeTemplate = template.Contains("::");
// use same extension as template, or ".cshtml" if it's a code template))
if (_webSiteFolder.FileExists(template)) {
if (!isCodeTemplate && _webSiteFolder.FileExists(template)) {
alternateFilename += Path.GetExtension(template);
using (var stream = System.IO.File.Create(alternateFilename)) {
@@ -41,7 +41,7 @@ namespace Orchard.DesignerTools.Controllers
}
else {
alternateFilename += ".cshtml";
using (System.IO.File.Create(alternateFilename)) {}
using (System.IO.File.Create(alternateFilename)) { }
}
return this.RedirectLocal(returnUrl);