diff --git a/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs
index 6380f8cc82..9235868bbc 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs
@@ -234,22 +234,6 @@ namespace Microsoft.AspNet.Mvc.Razor
return string.Format(CultureInfo.CurrentCulture, GetString("ViewContextMustBeSet"), p0, p1);
}
- ///
- /// View '{0}' must have extension '{1}' when the view represents a full path.
- ///
- internal static string ViewMustEndInExtension
- {
- get { return GetString("ViewMustEndInExtension"); }
- }
-
- ///
- /// View '{0}' must have extension '{1}' when the view represents a full path.
- ///
- internal static string FormatViewMustEndInExtension(object p0, object p1)
- {
- return string.Format(CultureInfo.CurrentCulture, GetString("ViewMustEndInExtension"), p0, p1);
- }
-
///
/// The method '{0}' cannot be invoked by this view.
///
diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
index b423f35511..a9ff53396f 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorViewEngine.cs
@@ -78,16 +78,15 @@ namespace Microsoft.AspNet.Mvc.Razor
if (nameRepresentsPath)
{
- if (!viewName.EndsWith(ViewExtension, StringComparison.OrdinalIgnoreCase))
+ if (viewName.EndsWith(ViewExtension, StringComparison.OrdinalIgnoreCase))
{
- throw new InvalidOperationException(
- Resources.FormatViewMustEndInExtension(viewName, ViewExtension));
+ var page = _pageFactory.CreateInstance(viewName);
+ if (page != null)
+ {
+ return CreateFoundResult(page, viewName, partial);
+ }
}
-
- var page = _pageFactory.CreateInstance(viewName);
-
- return page != null ? CreateFoundResult(page, viewName, partial) :
- ViewEngineResult.NotFound(viewName, new[] { viewName });
+ return ViewEngineResult.NotFound(viewName, new[] { viewName });
}
else
{
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Resources.resx b/src/Microsoft.AspNet.Mvc.Razor/Resources.resx
index bae45587d0..44185c3b9c 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/Resources.resx
+++ b/src/Microsoft.AspNet.Mvc.Razor/Resources.resx
@@ -159,9 +159,6 @@
'{0} must be set to access '{1}'.
-
- View '{0}' must have extension '{1}' when the view represents a full path.
-
The method '{0}' cannot be invoked by this view.
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewEngineTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewEngineTest.cs
index 94701b0ddb..6fd7bbe963 100644
--- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewEngineTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorViewEngineTest.cs
@@ -38,15 +38,17 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[Theory]
[MemberData("InvalidViewNameValues")]
- public void FindViewFullPathFailsWithNoCshtmlEnding(string viewName)
+ public void FindView_WithFullPathReturnsNotFound_WhenPathDoesNotMatchExtension(string viewName)
{
// Arrange
var viewEngine = CreateSearchLocationViewEngineTester();
var context = GetActionContext(_controllerTestContext);
- // Act & Assert
- Assert.Throws(() =>
- viewEngine.FindView(context, viewName));
+ // Act
+ var result = viewEngine.FindView(context, viewName);
+
+ // Assert
+ Assert.False(result.Success);
}
[Theory]
@@ -68,15 +70,17 @@ namespace Microsoft.AspNet.Mvc.Razor.Test
[Theory]
[MemberData("InvalidViewNameValues")]
- public void FindPartialViewFullPathFailsWithNoCshtmlEnding(string partialViewName)
+ public void FindPartialView_WithFullPathReturnsNotFound_WhenPathDoesNotMatchExtension(string partialViewName)
{
// Arrange
var viewEngine = CreateSearchLocationViewEngineTester();
var context = GetActionContext(_controllerTestContext);
- // Act & Assert
- Assert.Throws(() =>
- viewEngine.FindPartialView(context, partialViewName));
+ // Act
+ var result = viewEngine.FindPartialView(context, partialViewName);
+
+ // Assert
+ Assert.False(result.Success);
}
[Theory]