diff --git a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs
index d0b8569664..5eaef99206 100644
--- a/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor/RazorPage.cs
@@ -548,7 +548,8 @@ public virtual void WriteAttributeTo(
WritePositionTaggedLiteral(writer, prefix);
first = false;
}
- else
+
+ if (!string.IsNullOrEmpty(attrVal.Prefix))
{
WritePositionTaggedLiteral(writer, attrVal.Prefix);
}
diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/BasicTests.cs b/test/Microsoft.AspNet.Mvc.FunctionalTests/BasicTests.cs
index 2e6aa48800..27d539cfb5 100644
--- a/test/Microsoft.AspNet.Mvc.FunctionalTests/BasicTests.cs
+++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/BasicTests.cs
@@ -76,6 +76,24 @@ public async Task CanRender_SimpleViews()
Assert.Equal(expectedContent, responseContent);
}
+ [Fact]
+ public async Task ViewWithAttributePrefix_RendersWithoutIgnoringPrefix()
+ {
+ // Arrange
+ var server = TestHelper.CreateServer(_app, SiteName, _configureServices);
+ var client = server.CreateClient();
+ var expectedContent = await _resourcesAssembly.ReadResourceAsStringAsync(
+ "compiler/resources/BasicWebSite.Home.ViewWithPrefixedAttributeValue.html");
+
+ // Act
+ var response = await client.GetAsync("http://localhost/Home/ViewWithPrefixedAttributeValue");
+ var responseContent = await response.Content.ReadAsStringAsync();
+
+ // Assert
+ Assert.Equal(HttpStatusCode.OK, response.StatusCode);
+ Assert.Equal(expectedContent, responseContent);
+ }
+
[Fact]
public async Task CanReturn_ResultsWithoutContent()
{
diff --git a/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/BasicWebSite.Home.ViewWithPrefixedAttributeValue.html b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/BasicWebSite.Home.ViewWithPrefixedAttributeValue.html
new file mode 100644
index 0000000000..1deac72329
--- /dev/null
+++ b/test/Microsoft.AspNet.Mvc.FunctionalTests/compiler/resources/BasicWebSite.Home.ViewWithPrefixedAttributeValue.html
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs
index 5c9aaa6ab7..76edb91805 100644
--- a/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs
+++ b/test/Microsoft.AspNet.Mvc.Razor.Test/RazorPageTest.cs
@@ -667,6 +667,8 @@ public async Task WriteAttribute_CallsBeginAndEndContext_OnPageExecutionListener
var sequence = new MockSequence();
context.InSequence(sequence).Setup(f => f.BeginContext(0, 6, true)).Verifiable();
context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable();
+ context.InSequence(sequence).Setup(f => f.BeginContext(0, 6, true)).Verifiable();
+ context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable();
context.InSequence(sequence).Setup(f => f.BeginContext(8, 14, true)).Verifiable();
context.InSequence(sequence).Setup(f => f.EndContext()).Verifiable();
context.InSequence(sequence).Setup(f => f.BeginContext(22, 7, true)).Verifiable();
diff --git a/test/WebSites/BasicWebSite/Controllers/HomeController.cs b/test/WebSites/BasicWebSite/Controllers/HomeController.cs
index a16e9fa641..891a74efcf 100644
--- a/test/WebSites/BasicWebSite/Controllers/HomeController.cs
+++ b/test/WebSites/BasicWebSite/Controllers/HomeController.cs
@@ -86,7 +86,12 @@ public IActionResult JsonTextInView()
{
return View();
}
-
+
+ public IActionResult ViewWithPrefixedAttributeValue()
+ {
+ return View();
+ }
+
public string GetApplicationDescription()
{
var actionDescriptor = (ControllerActionDescriptor)ActionContext.ActionDescriptor;
diff --git a/test/WebSites/BasicWebSite/Views/Home/ViewWithPrefixedAttributeValue.cshtml b/test/WebSites/BasicWebSite/Views/Home/ViewWithPrefixedAttributeValue.cshtml
new file mode 100644
index 0000000000..cacc64999e
--- /dev/null
+++ b/test/WebSites/BasicWebSite/Views/Home/ViewWithPrefixedAttributeValue.cshtml
@@ -0,0 +1,7 @@
+@{
+ var attrValue = "Baz";
+}
+
+
+
+
\ No newline at end of file