Tag helpers

This commit is contained in:
Praburaj 2015-04-02 12:07:25 -07:00
parent 035c97a7bf
commit ba80195851
49 changed files with 296 additions and 311 deletions

View File

@ -13,6 +13,7 @@
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
<DevelopmentServerPort>1575</DevelopmentServerPort>
<GruntGulpQueried>True</GruntGulpQueried>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@ -1,6 +1,5 @@
using System.Linq;
using System.Security.Claims;
using System.Security.Principal;
using System.Threading.Tasks;
using Microsoft.AspNet.Authorization;
using Microsoft.AspNet.Hosting;

View File

@ -33,8 +33,6 @@ namespace MusicStore.Controllers
return View(albums);
}
//Can be removed and handled when HandleError filter is implemented
//https://github.com/aspnet/Mvc/issues/623
public IActionResult Error()
{
return View("~/Views/Shared/Error.cshtml");

View File

@ -0,0 +1,7 @@
namespace MusicStore
{
public class AppSettings
{
public string SiteTitle { get; set; }
}
}

View File

@ -1,8 +1,8 @@
/// <autosync enabled="true" />
/// <reference path="../wwwroot/Scripts/bootstrap.js" />
/// <reference path="../wwwroot/Scripts/jquery-2.0.3.js" />
/// <reference path="../wwwroot/Scripts/jquery.signalR-2.0.1.js" />
/// <reference path="../wwwroot/Scripts/jquery.validate.js" />
/// <reference path="../wwwroot/Scripts/jquery.validate.unobtrusive.js" />
/// <reference path="../wwwroot/Scripts/modernizr-2.6.2.js" />
/// <reference path="../wwwroot/Scripts/respond.js" />
/// <reference path="../wwwroot/Scripts/modernizr-2.6.2.js" />
/// <reference path="../wwwroot/Scripts/jquery.validate.unobtrusive.js" />
/// <reference path="../wwwroot/Scripts/jquery.validate.js" />
/// <reference path="../wwwroot/Scripts/jquery.signalR-2.0.1.js" />
/// <reference path="../wwwroot/Scripts/jquery-2.0.3.js" />
/// <reference path="../wwwroot/Scripts/bootstrap.js" />

View File

@ -28,6 +28,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
//Sql client not available on mono
var useInMemoryStore = Type.GetType("Mono.Runtime") != null;

View File

@ -43,6 +43,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
// Add EF services to the services container
services.AddEntityFramework()
.AddSqlServer()

View File

@ -41,6 +41,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
//Sql client not available on mono
var useInMemoryStore = Type.GetType("Mono.Runtime") != null;

View File

@ -5,6 +5,6 @@
<h2>@ViewBag.Title.</h2>
<div>
<p>
Thank you for confirming your email. Please @Html.ActionLink("Click here to Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })
Thank you for confirming your email. Please <a asp-controller="Account" asp-action="Login">Click here to Log in</a>.
</p>
</div>

View File

@ -1,27 +1,25 @@
@model MusicStore.Models.ExternalLoginConfirmationViewModel
@model ExternalLoginConfirmationViewModel
@{
ViewBag.Title = "Register";
}
<h2>@ViewBag.Title.</h2>
<h3>Associate your @ViewBag.LoginProvider account.</h3>
@using (Html.BeginForm("ExternalLoginConfirmation", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<form asp-controller="Account" asp-action="ExternalLoginConfirmation" asp-route-returnurl="@ViewBag.ReturnUrl" method="post" class="form-horizontal" role="form">
<h4>Association Form</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<p class="text-info">
You've successfully authenticated with <strong>@ViewBag.LoginProvider</strong>.
Please enter a user name for this site below and click the Register button to finish
logging in.
</p>
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@ -29,11 +27,8 @@
<input type="submit" class="btn btn-default" value="Register" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -5,4 +5,4 @@
<hgroup>
<h2>@ViewBag.Title.</h2>
<h3 class="text-danger">Unsuccessful login with service.</h3>
</hgroup>
</hgroup>

View File

@ -1,20 +1,19 @@
@model MusicStore.Models.ForgotPasswordViewModel
@model ForgotPasswordViewModel
@{
ViewBag.Title = "Forgot your password?";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("ForgotPassword", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<form asp-controller="Account" asp-action="ForgotPassword" method="post" class="form-horizontal" role="form">
<h4>Enter your email.</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@ -22,11 +21,8 @@
<input type="submit" class="btn btn-default" value="Email Link" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -10,6 +10,6 @@
Please check your email to reset your password.
</p>
<p>
For demo purpose only: @Html.ActionLink("Click here to reset the password: ", "ResetPassword", new { code = ViewBag.Code });
For demo purpose only: <a asp-action="ResetPassword" asp-route-code="@ViewBag.Code">Click here to reset the password</a>
</p>
</div>

View File

@ -1,5 +1,4 @@
@using MusicStore.Models
@model LoginViewModel
@model LoginViewModel
@{
ViewBag.Title = "Log in";
@ -9,31 +8,29 @@
<div class="row">
<div class="col-md-8">
<section id="loginForm">
@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<form asp-controller="Account" asp-action="Login" asp-route-returnurl="@ViewBag.ReturnUrl" method="post" class="form-horizontal" role="form">
<h4>Use a local account to log in.</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
<label asp-for="Password" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.Password, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<div class="checkbox">
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe)
<input asp-for="RememberMe" />
<label asp-for="RememberMe"></label>
</div>
</div>
</div>
@ -43,13 +40,12 @@
</div>
</div>
<p>
@Html.ActionLink("Register as a new user", "Register")
<a asp-action="Register">Register as a new user?</a>
</p>
@*Enable this once you have account confirmation enabled for password reset functionality*@
<p>
@Html.ActionLink("Forgot your password?", "ForgotPassword")
<a asp-action="ForgotPassword">Forgot your password?</a>
</p>
}
</form>
</section>
</div>
<div class="col-md-4">
@ -58,9 +54,7 @@
</section>
</div>
</div>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -1,32 +1,33 @@
@model MusicStore.Models.RegisterViewModel
@model RegisterViewModel
@{
ViewBag.Title = "Register";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<form asp-controller="Account" asp-action="Register" method="post" class="form-horizontal" role="form">
<h4>Create a new account.</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
<label asp-for="Password" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.Password, new { @class = "form-control" })
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" })
<label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" })
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@ -34,11 +35,8 @@
<input type="submit" class="btn btn-default" value="Register" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -10,6 +10,6 @@
Please check your email to activate your account.
</p>
<p>
Demo/testing purposes only: The sample displays the code and user id in the page: @Html.ActionLink("Click here to confirm your email: ", "ConfirmEmail", new { code = ViewBag.Code, userId = ViewBag.UserId })
Demo/testing purposes only: The sample displays the code and user id in the page: <a asp-action="ConfirmEmail" asp-route-code="@ViewBag.Code" asp-route-userId="@ViewBag.UserId">Click here to confirm your email: </a>
</p>
</div>

View File

@ -1,33 +1,34 @@
@model MusicStore.Models.ResetPasswordViewModel
@model ResetPasswordViewModel
@{
ViewBag.Title = "Reset password";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("ResetPassword", "Account", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<form asp-controller="Account" asp-action="ResetPassword" method="post" class="form-horizontal" role="form">
<h4>Reset your password.</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
@Html.HiddenFor(model => model.Code)
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<input asp-for="Code" type="hidden" />
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<label asp-for="Email" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
<label asp-for="Password" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.Password, new { @class = "form-control" })
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" })
<label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" })
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@ -35,11 +36,8 @@
<input type="submit" class="btn btn-default" value="Reset" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -7,6 +7,6 @@
</hgroup>
<div>
<p>
Your password has been reset. Please @Html.ActionLink("click here to log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })
Your password has been reset. Please <a asp-controller="Account" asp-action="Login">Click here to log in</a>.
</p>
</div>
</div>

View File

@ -1,28 +1,21 @@
@model MusicStore.Models.SendCodeViewModel
@model SendCodeViewModel
@{
ViewBag.Title = "Send";
ViewBag.Title = "Send Verification Code";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("SendCode", "Account", new { ReturnUrl = Model.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
@Html.Hidden("rememberMe", @Model.RememberMe)
<h4>Send verification code</h4>
<hr />
<form asp-controller="Account" asp-action="SendCode" asp-route-returnurl="@Model.ReturnUrl" method="post" class="form-horizontal" role="form">
<input asp-for="RememberMe" type="hidden" />
<div class="row">
<div class="col-md-8">
Select Two-Factor Authentication Provider:
@Html.DropDownListFor(model => model.SelectedProvider, Model.Providers)
<select asp-for="SelectedProvider" asp-items="Model.Providers"></select>
<input type="submit" value="Submit" class="btn btn-default" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
}
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -1,15 +1,14 @@
@model MusicStore.Models.VerifyCodeViewModel
@model VerifyCodeViewModel
@{
ViewBag.Title = "Verify";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("VerifyCode", "Account", new { ReturnUrl = Model.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
@Html.Hidden("provider", @Model.Provider)
@Html.Hidden("rememberMe", @Model.RememberMe)
<form asp-controller="Account" asp-action="VerifyCode" asp-route-returnurl="@Model.ReturnUrl" method="post" class="form-horizontal" role="form">
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<input asp-for="Provider" type="hidden" />
<input asp-for="RememberMe" type="hidden" />
<h4>Enter verification code</h4>
<p class="text-danger">
For DEMO only: You can type in this code in the below text box to proceed: [ @ViewBag.Code ]
@ -17,18 +16,18 @@
Please change this code to register an SMS/Email service in IdentityConfig to send a message.
</p>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(m => m.Code, new { @class = "col-md-2 control-label" })
<label asp-for="Code" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.TextBoxFor(m => m.Code, new { @class = "form-control" })
<input asp-for="Code" class="form-control" />
<span asp-validation-for="Code" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<div class="checkbox">
@Html.CheckBoxFor(m => m.RememberBrowser)
@Html.LabelFor(m => m.RememberBrowser)
<input asp-for="RememberBrowser" />
<label asp-for="RememberBrowser"></label>
</div>
</div>
</div>
@ -37,11 +36,8 @@
<input type="submit" class="btn btn-default" value="Submit" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
}
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -1,6 +1,4 @@
@using MusicStore.Models;
@using Microsoft.AspNet.Http.Authentication;
@using Microsoft.AspNet.Identity;
@using Microsoft.AspNet.Http.Authentication;
@model ExternalLoginListViewModel
@inject SignInManager<ApplicationUser> SignInManager
<h4>Use another service to log in.</h4>
@ -18,17 +16,15 @@
}
else
{
using (Html.BeginForm("ExternalLogin", "Account", new { ReturnUrl = Model.ReturnUrl }))
{
@Html.AntiForgeryToken()
<form asp-controller="Account" asp-action="ExternalLogin" asp-route-returnurl="@ViewBag.ReturnUrl" method="post" class="form-horizontal" role="form">
<div id="socialLoginList">
<p>
@foreach (AuthenticationDescription p in loginProviders.Where(a => a.Caption != null))
@foreach (AuthenticationDescription p in loginProviders)
{
<button type="submit" class="btn btn-default" id="@p.AuthenticationScheme" name="provider" value="@p.AuthenticationScheme" title="Log in using your @p.Caption account">@p.AuthenticationScheme</button>
}
</p>
</div>
}
</form>
}
}

View File

@ -1,22 +1,17 @@
@model MusicStore.Models.Order
@model Order
@{
ViewBag.Title = "Address And Payment";
}
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<form>
<h2>Address And Payment</h2>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<fieldset>
<legend>Shipping Information</legend>
@ -27,7 +22,7 @@
<p>We're running a promotion: all music is free with the promo code: "FREE"</p>
<div class="editor-label">
@Html.Label("Promo Code")
<label title="Promo Code">Promo Code</label>
</div>
<div class="editor-field">
@Html.TextBox("PromoCode")
@ -35,4 +30,4 @@
</fieldset>
<input type="submit" value="Submit Order" />
}
</form>

View File

@ -10,5 +10,5 @@
<p>
How about shopping for some more music in our
@Html.ActionLink("Store", "Index", "Home")
<a asp-controller="Home" asp-action="Index">Store</a>
</p>

View File

@ -1,20 +1,21 @@
@{
@inject IOptions<AppSettings> AppSettings
@{
ViewBag.Title = "Home Page";
}
<div class="jumbotron">
<h1>MVC Music Store</h1>
<h1>@AppSettings.Options.SiteTitle</h1>
<img src="~/Images/home-showcase.png" />
</div>
<ul class="row list-unstyled" id="album-list">
@foreach (var album in Model)
{
<li class="col-lg-2 col-md-2 col-sm-2 col-xs-4 container">
<a href="@Url.Action("Details", "Store", new { id = album.AlbumId })">
<img alt="@album.Title" src="@Url.Content(@album.AlbumArtUrl)" />
<h4>@album.Title</h4>
</a>
</li>
<li class="col-lg-2 col-md-2 col-sm-2 col-xs-4 container">
<a asp-controller="Store" asp-action="Details" asp-route-id="@album.AlbumId">
<img alt="@album.Title" src="@Url.Content(@album.AlbumArtUrl)" />
<h4>@album.Title</h4>
</a>
</li>
}
</ul>

View File

@ -1,32 +1,27 @@
@model MusicStore.Models.AddPhoneNumberViewModel
@model AddPhoneNumberViewModel
@{
ViewBag.Title = "Phone Number";
ViewBag.Title = "Add Phone Number";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("AddPhoneNumber", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Add a phone number</h4>
<form asp-controller="Manage" asp-action="AddPhoneNumber" method="post" class="form-horizontal" role="form">
<h4>Add a phone number.</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group">
@Html.LabelFor(m => m.Number, new { @class = "col-md-2 control-label" })
<label asp-for="Number" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.TextBoxFor(m => m.Number, new { @class = "form-control" })
<input asp-for="Number" class="form-control" />
<span asp-validation-for="Number" class="text-danger"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" class="btn btn-default" value="Submit" />
<input type="submit" class="btn btn-default" value="Send verification code" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -1,32 +1,33 @@
@model MusicStore.Models.ChangePasswordViewModel
@model ChangePasswordViewModel
@{
ViewBag.Title = "Change Password";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("ChangePassword", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<form asp-controller="Manage" asp-action="ChangePassword" method="post" class="form-horizontal" role="form">
<h4>Change Password Form</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group">
@Html.LabelFor(m => m.OldPassword, new { @class = "col-md-2 control-label" })
<label asp-for="OldPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.OldPassword, new { @class = "form-control" })
<input asp-for="OldPassword" class="form-control" />
<span asp-validation-for="OldPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" })
<label asp-for="NewPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" })
<input asp-for="NewPassword" class="form-control" />
<span asp-validation-for="NewPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" })
<label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" })
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@ -34,10 +35,8 @@
<input type="submit" value="Change password" class="btn btn-default" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
}
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -1,6 +1,6 @@
@model MusicStore.Models.IndexViewModel
@model IndexViewModel
@{
ViewBag.Title = "Manage";
ViewBag.Title = "Manage your account";
}
<h2>@ViewBag.Title.</h2>
@ -15,18 +15,17 @@
[
@if (Model.HasPassword)
{
@Html.ActionLink("Change your password", "ChangePassword")
<a asp-controller="Manage" asp-action="ChangePassword">Change</a>
}
else
{
@Html.ActionLink("Create", "SetPassword")
<a asp-controller="Manage" asp-action="SetPassword">Create</a>
}
]
</dd>
<dt>External Logins:</dt>
<dd>
@Model.Logins.Count [
@Html.ActionLink("Manage", "ManageLogins") ]
@Model.Logins.Count [<a asp-controller="Manage" asp-action="ManageLogins">Manage</a>]
</dd>
@*
Phone Numbers can used as a second factor of verification in a two-factor authentication system.
@ -42,13 +41,13 @@
@(Model.PhoneNumber ?? "None") [
@if (Model.PhoneNumber != null)
{
@Html.ActionLink("Change", "AddPhoneNumber")
<a asp-controller="Manage" asp-action="AddPhoneNumber">Change</a>
@: &nbsp;|&nbsp;
@Html.ActionLink("Remove", "RemovePhoneNumber")
<a asp-controller="Manage" asp-action="RemovePhoneNumber">Remove</a>
}
else
{
@Html.ActionLink("Add", "AddPhoneNumber")
<a asp-controller="Manage" asp-action="AddPhoneNumber">Add</a>
}
]
</dd>
@ -56,51 +55,43 @@
<dd>
@if (Model.TwoFactor)
{
using (Html.BeginForm("DisableTwoFactorAuthentication", "Manage", FormMethod.Post))
{
@Html.AntiForgeryToken()
<form asp-controller="Manage" asp-action="DisableTwoFactorAuthentication" method="post" class="form-horizontal" role="form">
<p>
Enabled
<input type="submit" value="Disable" class="btn btn-link" />
</p>
}
</form>
}
else
{
using (Html.BeginForm("EnableTwoFactorAuthentication", "Manage", FormMethod.Post))
{
@Html.AntiForgeryToken()
<form asp-controller="Manage" asp-action="EnableTwoFactorAuthentication" method="post" class="form-horizontal" role="form">
<p>
Disabled
<input type="submit" value="Enable" class="btn btn-link" />
</p>
}
</form>
}
</dd>
<dt>Browser remembered:</dt>
<dd>
@if (Model.BrowserRemembered)
{
using (Html.BeginForm("ForgetBrowser", "Manage", FormMethod.Post))
{
@Html.AntiForgeryToken()
<form asp-controller="Manage" asp-action="ForgetBrowser" method="post" class="form-horizontal" role="form">
<p>
Browser is curently remembered for two factor:
<input type="submit" value="Forget Browser" class="btn btn-default" />
</p>
}
</form>
}
else
{
using (Html.BeginForm("RememberBrowser", "Manage", FormMethod.Post))
{
@Html.AntiForgeryToken()
<form asp-controller="Manage" asp-action="ForgetBrowser" method="post" class="form-horizontal" role="form">
<p>
Browser is curently not remembered for two factor:
<input type="submit" value="Remember Browser" class="btn btn-default" />
</p>
}
</form>
}
</dd>
</dl>
</div>
</div>

View File

@ -1,5 +1,5 @@
@using Microsoft.AspNet.Http.Authentication;
@model MusicStore.Models.ManageLoginsViewModel
@model ManageLoginsViewModel
@{
ViewBag.Title = "Manage your external logins";
}
@ -13,21 +13,19 @@
<table class="table">
<tbody>
@foreach (var account in Model.CurrentLogins)
{
{
<tr>
<td>@account.LoginProvider</td>
<td>
@if (ViewBag.ShowRemoveButton)
{
using (Html.BeginForm("RemoveLogin", "Manage"))
{
@Html.AntiForgeryToken()
<form asp-controller="Manage" asp-action="RemoveLogin" method="post" class="form-horizontal" role="form">
<div>
@Html.Hidden("loginProvider", account.LoginProvider)
@Html.Hidden("providerKey", account.ProviderKey)
<input asp-for="@account.LoginProvider" type="hidden" />
<input asp-for="@account.ProviderKey" type="hidden" />
<input type="submit" class="btn btn-default" value="Remove" title="Remove this @account.LoginProvider login from your account" />
</div>
}
</form>
}
else
{
@ -43,16 +41,14 @@
{
<h4>Add another service to log in.</h4>
<hr />
using (Html.BeginForm("LinkLogin", "Manage"))
{
@Html.AntiForgeryToken()
<form asp-controller="Manage" asp-action="LinkLogin" method="post" class="form-horizontal" role="form">
<div id="socialLoginList">
<p>
@foreach (AuthenticationDescription p in Model.OtherLogins)
{
{
<button type="submit" class="btn btn-default" id="@p.AuthenticationScheme" name="provider" value="@p.AuthenticationScheme" title="Log in using your @p.Caption account">@p.AuthenticationScheme</button>
}
</p>
</div>
}
</form>
}

View File

@ -1,31 +1,29 @@
@model MusicStore.Models.SetPasswordViewModel
@model SetPasswordViewModel
@{
ViewBag.Title = "Create Password";
ViewBag.Title = "Set Password";
}
<h2>@ViewBag.Title.</h2>
<p class="text-info">
You do not have a local username/password for this site. Add a local
account so you can log in without an external login.
</p>
@using (Html.BeginForm("SetPassword", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
<h4>Create Local Login</h4>
<form asp-controller="Manage" asp-action="SetPassword" method="post" class="form-horizontal" role="form">
<h4>Set your password</h4>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group">
@Html.LabelFor(m => m.NewPassword, new { @class = "col-md-2 control-label" })
<label asp-for="NewPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.NewPassword, new { @class = "form-control" })
<input asp-for="NewPassword" class="form-control" />
<span asp-validation-for="NewPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.ConfirmPassword, new { @class = "col-md-2 control-label" })
<label asp-for="ConfirmPassword" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control" })
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@ -33,11 +31,8 @@
<input type="submit" value="Set password" class="btn btn-default" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -1,14 +1,12 @@
@model MusicStore.Models.VerifyPhoneNumberViewModel
@model VerifyPhoneNumberViewModel
@{
ViewBag.Title = "Verify Phone Number";
}
<h2>@ViewBag.Title.</h2>
@using (Html.BeginForm("VerifyPhoneNumber", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
@Html.AntiForgeryToken()
@Html.Hidden("phoneNumber", @Model.PhoneNumber)
<form asp-controller="Manage" asp-action="VerifyPhoneNumber" method="post" class="form-horizontal" role="form">
<input asp-for="PhoneNumber" type="hidden" />
<h4>Enter verification code</h4>
<p class="text-danger">
For DEMO only: You can type in this code in the below text box to proceed: @ViewBag.Code
@ -16,11 +14,12 @@
Please change this code to register an SMS service in IdentityConfig to send a text message.
</p>
<hr />
@Html.ValidationSummary("", new { @class = "text-danger" })
<div asp-validation-summary="ValidationSummary.All" class="text-danger"></div>
<div class="form-group">
@Html.LabelFor(m => m.Code, new { @class = "col-md-2 control-label" })
<label asp-for="Code" class="col-md-2 control-label"></label>
<div class="col-md-10">
@Html.TextBoxFor(m => m.Code, new { @class = "form-control" })
<input asp-for="Code" class="form-control" />
<span asp-validation-for="Code" class="text-danger"></span>
</div>
</div>
<div class="form-group">
@ -28,11 +27,8 @@
<input type="submit" class="btn btn-default" value="Submit" />
</div>
</div>
}
</form>
@section Scripts {
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jqueryval")*@
<script src="@Url.Content("~/Scripts/jquery.validate.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script>
@{await Html.RenderPartialAsync("_ValidationScriptsPartial"); }
}

View File

@ -1,10 +1,10 @@
@model MusicStore.Models.Album
@model Album
@if (Model != null)
{
<li>
<br />
<small><i>@Html.Label(null, "New Arrivals!", new { style = "color: red" })</i></small>
<i>@Html.ActionLink(Model.Title, "Details", "Store", new { id = Model.AlbumId }, new { id = "NewArrivalsPanel" })</i>
<small><i><label title="New Arrivals!" style="color:red">New Arrivals!</label></i></small>
<i><a id="NewArrivalsPanel" asp-controller="Store" asp-action="Details" asp-route-id="@Model.AlbumId">@Model.Title</a></i>
</li>
}

View File

@ -1,7 +1,7 @@
@if (ViewBag.CartCount > 0)
{
<li>
<a href="@Url.Action("Index", "ShoppingCart")" title="@ViewBag.CartSummary">
<a asp-controller="ShoppingCart" asp-action="Index" title="@ViewBag.CartSummary">
<span class="glyphicon glyphicon glyphicon-shopping-cart"></span>
@ViewBag.CartCount
</a>

View File

@ -1,19 +1,17 @@
@model IEnumerable<MusicStore.Models.Genre>
@model IEnumerable<Genre>
<li class="dropdown">
<a href="@Url.Action("Index", "Store")" class="dropdown-toggle" data-toggle="dropdown">Store <b class="caret"></b></a>
<a asp-controller="Store" asp-action="Index" class="dropdown-toggle" data-toggle="dropdown">Store <b class="caret"></b></a>
<ul class="dropdown-menu">
@foreach (var genre in Model)
{
<li>
@Html.ActionLink(genre.Name,
"Browse", "Store",
new { Genre = genre.Name }, null)
<a asp-controller="Store" asp-action="Browse" asp-route-Genre="@genre.Name">@genre.Name</a>
</li>
}
<li class="divider"></li>
<li>
@Html.ActionLink("More...", "Index", "Store")
<a asp-controller="Store" asp-action="Index">More...</a>
</li>
</ul>
</li>

View File

@ -1,15 +1,25 @@
<!DOCTYPE html>
@inject IOptions<AppSettings> AppSettings
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title MVC Music Store</title>
<title>@ViewBag.Title @AppSettings.Options.SiteTitle</title>
<environment names="Development,NtlmAuthentication,OpenIdConnect,SocialTesting">
<link rel="stylesheet" href="~/Content/bootstrap.css" />
<link rel="stylesheet" href="~/Content/Site.css" />
<script src="~/Scripts/jquery-2.0.3.js"></script>
</environment>
<environment names="Staging,Production">
<link rel="stylesheet" href="//ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/css/bootstrap.min.css"
asp-fallback-href="~/Content/bootstrap.min.css"
asp-fallback-test-class="hidden"
asp-fallback-test-property="visibility" asp-fallback-test-value="hidden" />
<link rel="stylesheet" href="~/Content/Site.css" />
<script src="~/Scripts/jquery-2.0.3.min.js"></script>
</environment>
@*TODO : Until script helpers are available, adding script references manually*@
@*@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")*@
<link rel="stylesheet" href="~/Content/bootstrap.min.css" />
<link rel="stylesheet" href="~/Content/Site.css" />
<script type="text/javascript" src="~/Scripts/modernizr-2.6.2.js"></script>
<script src="~/Scripts/jquery-2.0.3.js"></script>
<script src="~/Scripts/jquery.signalR-2.0.1.min.js"></script>
@ -41,11 +51,11 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("ASP.NET MVC Music Store", "Index", "Home", null, new { @class = "navbar-brand" })
<a asp-controller="Home" asp-action="Index" class="navbar-brand">@AppSettings.Options.SiteTitle</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li><a asp-controller="Home" asp-action="Index">Home</a></li>
@await Component.InvokeAsync("GenreMenu")
@await Component.InvokeAsync("CartSummary")
@await Component.InvokeAsync("Announcement")
@ -63,11 +73,20 @@
</footer>
</div>
@*TODO : Until script helpers are available, adding script references manually*@
@*@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")*@
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/respond.js"></script>
<environment names="Development,NtlmAuthentication,OpenIdConnect,SocialTesting">
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/respond.js"></script>
</environment>
<environment names="Staging,Production">
<script src="//ajax.aspnetcdn.com/ajax/bootstrap/3.0.0/bootstrap.min.js"
asp-fallback-src="~/Scripts/bootstrap.min.js"
asp-fallback-test="window.jQuery">
</script>
<script src="//ajax.aspnetcdn.com/ajax/respond/1.2.0/respond.js"
asp-fallback-src="~/Scripts/respond.js">
</script>
</environment>
@RenderSection("scripts", required: false)
</body>
</html>

View File

@ -2,19 +2,15 @@
@if (User.IsSignedIn())
{
using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
{
@Html.AntiForgeryToken()
<form asp-controller="Account" asp-action="LogOff" method="post" id="logoutForm" class="navbar-right">
<ul class="nav navbar-nav navbar-right">
<li>
@Html.ActionLink("Hello " + User.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
<a asp-controller="Manage" asp-action="Index" title="Manage">Hello @User.GetUserName()!</a>
</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
</ul>
}
</form>
}
//Either NTLM will be used or social authentication will be used. Based on the authentication schemes enabled remove an unused block.
else if (User.Identity.IsAuthenticated)
{
//This code block necessary only for NTLM authentication
@ -27,7 +23,7 @@ else if (User.Identity.IsAuthenticated)
else
{
<ul class="nav navbar-nav navbar-right">
<li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" })</li>
<li>@Html.ActionLink("Log in", "Login", "Account", routeValues: null, htmlAttributes: new { id = "loginLink" })</li>
<li><a id="registerLink" asp-controller="Account" asp-action="Register">Register</a></li>
<li><a id="loginLink" asp-controller="Account" asp-action="Login">Log in</a></li>
</ul>
}

View File

@ -0,0 +1,14 @@
<environment names="Development,NtlmAuthentication,OpenIdConnect,SocialTesting">
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
</environment>
<environment names="Staging,Production">
<script src="//ajax.aspnetcdn.com/ajax/jquery.validation/1.11.1/jquery.validate.min.js"
asp-fallback-src="~/Scripts/jquery.validate.js"
asp-fallback-test="window.jquery && window.jquery.validator">
</script>
<script src="//ajax.aspnetcdn.com/ajax/mvc/5.2.3/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/Scripts/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jquery && window.jquery.validator && window.jquery.validator.unobtrusive">
</script>
</environment>

View File

@ -55,7 +55,7 @@
<em>Review</em> your cart:
</h3>
<p class="button">
@Html.ActionLink("Checkout >>", "AddressAndPayment", "Checkout")
<a asp-controller="Checkout" asp-action="AddressAndPayment">Checkout >></a>
</p>
<div id="update-message">
</div>
@ -76,8 +76,7 @@
{
<tr id="row-@item.CartItemId">
<td>
@Html.ActionLink(item.Album.Title,
"Details", "Store", new { id = item.AlbumId }, null)
<a asp-controller="Store" asp-action="Details" asp-route-id="@item.AlbumId">@item.Album.Title</a>
</td>
<td>
@item.Album.Price

View File

@ -1,4 +1,4 @@
@model MusicStore.Models.Genre
@model Genre
@{
ViewBag.Title = "Browse Albums";
}
@ -11,7 +11,7 @@
@foreach (var album in Model.Albums)
{
<li class="col-lg-2 col-md-2 col-sm-2 col-xs-4 container">
<a href="@Url.Action("Details", new { id = album.AlbumId })">
<a asp-controller="Store" asp-action="Details" asp-route-id="@album.AlbumId">
@if (!string.IsNullOrEmpty(album.AlbumArtUrl))
{
<img alt="@album.Title" src="@Url.Content(@album.AlbumArtUrl)" />

View File

@ -1,4 +1,4 @@
@model MusicStore.Models.Album
@model Album
@{
ViewBag.Title = "Album - " + Model.Title;
@ -21,9 +21,9 @@
</p>
<p>
<em>Price:</em>
@Html.DisplayFor(model => model.Price)
<label>@Model.Price</label>
</p>
<p class="button">
@Html.ActionLink("Add to cart", "AddToCart", "ShoppingCart", new { id = Model.AlbumId })
<a asp-controller="ShoppingCart" asp-action="AddToCart" asp-route-id="@Model.AlbumId">Add to cart</a>
</p>
</div>

View File

@ -1,4 +1,4 @@
@model IEnumerable<MusicStore.Models.Genre>
@model IEnumerable<Genre>
@{
ViewBag.Title = "Store";
}
@ -10,6 +10,6 @@
<ul class="list-group">
@foreach (var genre in Model)
{
<li class="list-group-item">@Html.ActionLink(genre.Name, "Browse", new { genre = genre.Name })</li>
<li class="list-group-item"><a asp-controller="Store" asp-action="Browse" asp-route-genre="@genre.Name">@genre.Name</a></li>
}
</ul>

View File

@ -0,0 +1,5 @@
@using MusicStore
@using MusicStore.Models
@using Microsoft.Framework.OptionsModel
@using Microsoft.AspNet.Identity
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"

View File

@ -1,4 +1,7 @@
{
"AppSettings": {
"SiteTitle": "ASP.NET MVC Music Store"
},
"DefaultAdminUsername": "Administrator@test.com",
"DefaultAdminPassword": "YouShouldChangeThisPassword1!",
"Data": {

View File

@ -24,11 +24,13 @@
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*",
"Microsoft.AspNet.Mvc": "6.0.0-*",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-*",
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
"Microsoft.AspNet.Session": "1.0.0-*",
"Microsoft.AspNet.SignalR.Server": "3.0.0-*",
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
"Microsoft.Framework.Caching.Distributed": "1.0.0-*", // For Session.
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-*",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*",

View File

@ -419,7 +419,7 @@ namespace E2ETests
}
catch (Exception exception)
{
logger.LogWarning("Failed to delete directory.", exception);
logger.LogWarning("Failed to delete directory : {error}", exception.Message);
}
}
}

View File

@ -34,11 +34,11 @@ namespace E2ETests
#endif
)
{
logger.LogWarning("Failed to complete the request.", exception);
logger.LogWarning("Failed to complete the request : {0}.", exception.Message);
Thread.Sleep(7 * 1000); //Wait for a while before retry.
}
}
}
}
}
}
}

View File

@ -46,7 +46,7 @@ namespace E2ETests
{
foreach (XmlNode input in htmlDocument.GetElementsByTagName("input"))
{
if (input.Attributes["name"].Value == "__RequestVerificationToken" && input.Attributes["type"].Value == "hidden")
if (input.Attributes["name"]?.Value == "__RequestVerificationToken" && input.Attributes["type"].Value == "hidden")
{
return input.Attributes["value"].Value;
}

View File

@ -43,7 +43,7 @@ namespace E2ETests
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
ValidateLayoutPage(responseContent);
Assert.Contains(PrefixBaseAddress("<a href=\"/{0}/Store/Details/"), responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<title>Home Page MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<title>Home Page ASP.NET MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase);
if (!useNtlmAuthentication)
{
@ -87,7 +87,7 @@ namespace E2ETests
{
Assert.Contains("ASP.NET MVC Music Store", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains(PrefixBaseAddress("<li><a href=\"/{0}\">Home</a></li>"), responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains(PrefixBaseAddress("<a href=\"/{0}/Store\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">Store <b class=\"caret\"></b></a>"), responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains(PrefixBaseAddress("<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"/{0}/Store\">Store <b class=\"caret\"></b></a>"), responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<ul class=\"dropdown-menu\">", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<li class=\"divider\"></li>", responseContent, StringComparison.OrdinalIgnoreCase);
}
@ -99,7 +99,7 @@ namespace E2ETests
ThrowIfResponseStatusNotOk(response);
var responseContent = response.Content.ReadAsStringAsync().Result;
ValidateLayoutPage(responseContent);
Assert.Contains("<title>Log in MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<title>Log in ASP.NET MVC Music Store</title>", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<h4>Use a local account to log in.</h4>", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Equal<string>(_applicationBaseUrl + PrefixBaseAddress("Account/Login?ReturnUrl=%2F{0}%2FAdmin%2FStoreManager%2F"), response.RequestMessage.RequestUri.AbsoluteUri);
_logger.LogInformation("Redirected to login page as expected.");
@ -137,7 +137,7 @@ namespace E2ETests
response = _httpClient.PostAsync("Account/Register", content).Result;
responseContent = response.Content.ReadAsStringAsync().Result;
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
Assert.Contains("<div class=\"validation-summary-errors text-danger\" data-valmsg-summary=\"true\"><ul><li>The password and confirmation password do not match.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<div class=\"text-danger validation-summary-errors\" data-valmsg-summary=\"true\"><ul><li>The password and confirmation password do not match.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
_logger.LogInformation("Server side model validator rejected the user '{email}''s registration as passwords do not match.", generatedEmail);
}
@ -249,7 +249,7 @@ namespace E2ETests
var content = new FormUrlEncodedContent(formParameters.ToArray());
response = _httpClient.PostAsync("Account/Login", content).Result;
responseContent = response.Content.ReadAsStringAsync().Result;
Assert.Contains("<div class=\"validation-summary-errors text-danger\"><ul><li>Invalid login attempt.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
Assert.Contains("<div class=\"text-danger validation-summary-errors\" data-valmsg-summary=\"true\"><ul><li>Invalid login attempt.</li>", responseContent, StringComparison.OrdinalIgnoreCase);
//Verify cookie not sent
Assert.Null(_httpClientHandler.CookieContainer.GetCookies(new Uri(_applicationBaseUrl)).GetCookieWithName(".AspNet.Microsoft.AspNet.Identity.Application"));
_logger.LogInformation("Identity successfully prevented an invalid user login.");

View File

@ -31,6 +31,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
//Sql client not available on mono
var useInMemoryStore = Type.GetType("Mono.Runtime") != null;

View File

@ -39,6 +39,8 @@ namespace MusicStore
public void ConfigureServices(IServiceCollection services)
{
services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
//Sql client not available on mono
string value;
var useInMemoryStore = Configuration.TryGet("UseInMemoryStore", out value) && value == "true" ?