Code cleanup
This commit is contained in:
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System.Diagnostics;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using MyWebsite.Models;
|
using MyWebsite.Models;
|
||||||
|
|
||||||
@@ -10,34 +6,11 @@ namespace MyWebsite.Controllers
|
|||||||
{
|
{
|
||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
public IActionResult Index()
|
public IActionResult Index() =>
|
||||||
{
|
View();
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IActionResult About()
|
|
||||||
{
|
|
||||||
ViewData["Message"] = "Your application description page.";
|
|
||||||
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IActionResult Contact()
|
|
||||||
{
|
|
||||||
ViewData["Message"] = "Your contact page.";
|
|
||||||
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IActionResult Privacy()
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public IActionResult Error()
|
public IActionResult Error() =>
|
||||||
{
|
View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
using System;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.HttpsPolicy;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@@ -37,16 +32,9 @@ namespace MyWebsite
|
|||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||||
{
|
|
||||||
if (env.IsDevelopment())
|
|
||||||
{
|
|
||||||
app.UseDeveloperExceptionPage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
app.UseExceptionHandler("/Home/Error");
|
app.UseExceptionHandler("/Home/Error");
|
||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "About";
|
|
||||||
}
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
|
||||||
<h3>@ViewData["Message"]</h3>
|
|
||||||
|
|
||||||
<p>Use this area to provide additional information.</p>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "Contact";
|
|
||||||
}
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
|
||||||
<h3>@ViewData["Message"]</h3>
|
|
||||||
|
|
||||||
<address>
|
|
||||||
One Microsoft Way<br />
|
|
||||||
Redmond, WA 98052-6399<br />
|
|
||||||
<abbr title="Phone">P:</abbr>
|
|
||||||
425.555.0100
|
|
||||||
</address>
|
|
||||||
|
|
||||||
<address>
|
|
||||||
<strong>Support:</strong> <a href="mailto:Support@example.com">Support@example.com</a><br />
|
|
||||||
<strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a>
|
|
||||||
</address>
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "Home Page";
|
|
||||||
}
|
|
||||||
|
|
||||||
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
|
|
||||||
<ol class="carousel-indicators">
|
|
||||||
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
|
|
||||||
<li data-target="#myCarousel" data-slide-to="1"></li>
|
|
||||||
<li data-target="#myCarousel" data-slide-to="2"></li>
|
|
||||||
</ol>
|
|
||||||
<div class="carousel-inner" role="listbox">
|
|
||||||
<div class="item active">
|
|
||||||
<img src="~/images/banner1.svg" alt="ASP.NET" class="img-responsive" />
|
|
||||||
<div class="carousel-caption" role="option">
|
|
||||||
<p>
|
|
||||||
Learn how to build ASP.NET apps that can run anywhere.
|
|
||||||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525028&clcid=0x409">
|
|
||||||
Learn More
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="item">
|
|
||||||
<img src="~/images/banner2.svg" alt="Visual Studio" class="img-responsive" />
|
|
||||||
<div class="carousel-caption" role="option">
|
|
||||||
<p>
|
|
||||||
There are powerful new features in Visual Studio for building modern web apps.
|
|
||||||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525030&clcid=0x409">
|
|
||||||
Learn More
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="item">
|
|
||||||
<img src="~/images/banner3.svg" alt="Microsoft Azure" class="img-responsive" />
|
|
||||||
<div class="carousel-caption" role="option">
|
|
||||||
<p>
|
|
||||||
Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps.
|
|
||||||
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525027&clcid=0x409">
|
|
||||||
Learn More
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
|
|
||||||
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
|
|
||||||
<span class="sr-only">Previous</span>
|
|
||||||
</a>
|
|
||||||
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
|
|
||||||
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
|
|
||||||
<span class="sr-only">Next</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-3">
|
|
||||||
<h2>Application uses</h2>
|
|
||||||
<ul>
|
|
||||||
<li>Sample pages using ASP.NET Core MVC</li>
|
|
||||||
<li>Theming using <a href="https://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<h2>How to</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<h2>Overview</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-3">
|
|
||||||
<h2>Run & Deploy</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li>
|
|
||||||
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
@{
|
|
||||||
ViewData["Title"] = "Privacy Policy";
|
|
||||||
}
|
|
||||||
<h2>@ViewData["Title"]</h2>
|
|
||||||
|
|
||||||
<p>Use this page to detail your site's privacy policy.</p>
|
|
||||||
@@ -3,20 +3,25 @@
|
|||||||
ViewData["Title"] = "Error";
|
ViewData["Title"] = "Error";
|
||||||
}
|
}
|
||||||
|
|
||||||
<h1 class="text-danger">Error.</h1>
|
<header>
|
||||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
<h1>Error.</h1>
|
||||||
|
<h2>An error occurred while processing your request.</h2>
|
||||||
|
</header>
|
||||||
|
|
||||||
@if (Model.ShowRequestId)
|
<article class="info-block">
|
||||||
{
|
@if (Model.ShowRequestId)
|
||||||
|
{
|
||||||
<p>
|
<p>
|
||||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
<h3>Development Mode</h3>
|
<h3>Development Mode</h3>
|
||||||
<p>
|
<p>
|
||||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
|
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
|
||||||
</p>
|
</p>
|
||||||
|
</article>
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
@using Microsoft.AspNetCore.Http.Features
|
|
||||||
|
|
||||||
@{
|
|
||||||
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
|
|
||||||
var showBanner = !consentFeature?.CanTrack ?? false;
|
|
||||||
var cookieString = consentFeature?.CreateConsentCookie();
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (showBanner)
|
|
||||||
{
|
|
||||||
<nav id="cookieConsent" class="navbar navbar-default navbar-fixed-top" role="alert">
|
|
||||||
<div class="container">
|
|
||||||
<div class="navbar-header">
|
|
||||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#cookieConsent .navbar-collapse">
|
|
||||||
<span class="sr-only">Toggle cookie consent banner</span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
<span class="icon-bar"></span>
|
|
||||||
</button>
|
|
||||||
<span class="navbar-brand"><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span></span>
|
|
||||||
</div>
|
|
||||||
<div class="collapse navbar-collapse">
|
|
||||||
<p class="navbar-text">
|
|
||||||
Use this space to summarize your privacy and cookie use policy.
|
|
||||||
</p>
|
|
||||||
<div class="navbar-right">
|
|
||||||
<a asp-controller="Home" asp-action="Privacy" class="btn btn-info navbar-btn">Learn More</a>
|
|
||||||
<button type="button" class="btn btn-default navbar-btn" data-cookie-string="@cookieString">Accept</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<script>
|
|
||||||
(function () {
|
|
||||||
document.querySelector("#cookieConsent button[data-cookie-string]").addEventListener("click", function (el) {
|
|
||||||
document.cookie = el.target.dataset.cookieString;
|
|
||||||
document.querySelector("#cookieConsent").classList.add("hidden");
|
|
||||||
}, false);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
<environment include="Development">
|
|
||||||
<script src="~/lib/jquery-validation/dist/jquery.validate.js"></script>
|
|
||||||
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
|
|
||||||
</environment>
|
|
||||||
<environment exclude="Development">
|
|
||||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.17.0/jquery.validate.min.js"
|
|
||||||
asp-fallback-src="~/lib/jquery-validation/dist/jquery.validate.min.js"
|
|
||||||
asp-fallback-test="window.jQuery && window.jQuery.validator"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
integrity="sha384-rZfj/ogBloos6wzLGpPkkOr/gpkBNLZ6b6yLy4o+ok+t/SAKlL5mvXLr0OXNi1Hp">
|
|
||||||
</script>
|
|
||||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.9/jquery.validate.unobtrusive.min.js"
|
|
||||||
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
|
|
||||||
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
integrity="sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds">
|
|
||||||
</script>
|
|
||||||
</environment>
|
|
||||||
Reference in New Issue
Block a user