Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/Mvc/samples/MvcSandbox/MvcSandbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.AspNetCore.Mvc.Components.Prerendering" />
<Reference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
<Reference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Runtime compilation doesn't work in the sandbox. It needs PreserveCompilationReferences to be set.

<Reference Include="Microsoft.AspNetCore.Components.Server" />
<Reference Include="Microsoft.AspNetCore.Diagnostics" />
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration" />
Expand Down
22 changes: 4 additions & 18 deletions src/Mvc/samples/MvcSandbox/Pages/PagesHome.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,7 @@
public string Message { get; set; }
}

<div class="row">
<div class="col-md-3">
<h2>RazorPages says Hello @Model.Name!</h2>
<ul>
<li>This file should give you a quick view of a Mvc Razor Page in action.</li>
</ul>
<p>Message from TempData: @Message</p>
@{
Message = $"You visited this page at {DateTime.Now}.";
}
</div>

<form method="post">
<label>Say hello to <input type="text" name="name" /></label>
<input type="submit" value="Say" />
</form>

</div>
<div class="text-center">
<h1 class="display-4">Pages Home</h1>
<p>This sandbox should give you a quick view of a basic MVC application.</p>
</div>
2 changes: 0 additions & 2 deletions src/Mvc/samples/MvcSandbox/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand All @@ -28,7 +27,6 @@ public void ConfigureServices(IServiceCollection services)
});
services.AddServerSideBlazor();
services.AddMvc()
.AddRazorRuntimeCompilation()
.SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Latest);
}

Expand Down
10 changes: 3 additions & 7 deletions src/Mvc/samples/MvcSandbox/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
ViewData["Title"] = "Home Page";
}

<div class="row">
<div class="col-md-3">
<h2>Sandbox</h2>
<ul>
<li>This sandbox should give you a quick view of a basic MVC application.</li>
</ul>
</div>
<div class="text-center">
<h1 class="display-4">Sandbox</h1>
<p>This sandbox should give you a quick view of a basic MVC application.</p>
</div>
51 changes: 23 additions & 28 deletions src/Mvc/samples/MvcSandbox/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,34 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - MvcSandbox</title>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" />
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a asp-controller="Home" asp-action="Index" class="navbar-brand">MvcSandbox</a>
<header>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the newer layout so everything isn't hidden around the fixed nav-bar

<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">MvcSandbox</a>
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-page="/PagesHome">Pages Home</a>
</li>
</ul>
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-controller="Home" asp-action="Index">Home</a></li>
<li><a asp-page="/PagesHome">PagesHome</a></li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>&copy; 2015 - MvcSandbox</p>
</footer>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>

<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js"></script>

<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
@RenderSection("scripts", required: false)
</body>
</html>
10 changes: 6 additions & 4 deletions src/Mvc/test/Mvc.FunctionalTests/MvcSandboxTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Xunit;
Expand All @@ -20,19 +21,20 @@ public MvcSandboxTest(MvcTestFixture<MvcSandbox.Startup> fixture)
public async Task Home_Pages_ReturnSuccess()
{
// Arrange & Act
var response = await Client.GetStringAsync("http://localhost");
var response = await Client.GetAsync("http://localhost");

// Assert
Assert.Contains("This sandbox should give you a quick view of a basic MVC application.", response);
await response.AssertStatusCodeAsync(HttpStatusCode.OK);
}

[Fact]
public async Task RazorPages_ReturnSuccess()
{
// Arrange & Act
var response = await Client.GetStringAsync("http://localhost/PagesHome");
var response = await Client.GetAsync("http://localhost/PagesHome");

// Assert
Assert.Contains("This file should give you a quick view of a Mvc Razor Page in action.", response);
await response.AssertStatusCodeAsync(HttpStatusCode.OK);
}
}
}