Clean up and refactoring
1. Removed some console logging statements from code 2. Used database error page like templates. 3. Renamed the command `WebListener` to `web` with all lower case to be consistent with templates. 4. Lowercased `Kestrel` => `kestrel` to be consistent with remaining samples.
This commit is contained in:
parent
d9148bd6f7
commit
e609602f2f
|
|
@ -14,9 +14,9 @@ This project is part of ASP.NET 5.0. You can find samples, documentation and get
|
||||||
## Run on WebListener/Kestrel:
|
## Run on WebListener/Kestrel:
|
||||||
* Open a command prompt and cd `\src\MusicStore\`.
|
* Open a command prompt and cd `\src\MusicStore\`.
|
||||||
* **[WebListener]:**
|
* **[WebListener]:**
|
||||||
4. Run `k WebListener` (Application started at URL **http://localhost:5002/**).
|
4. Run `k web` (Application started at URL **http://localhost:5002/**).
|
||||||
* **[Kestrel]:**
|
* **[Kestrel]:**
|
||||||
5. Run `k Kestrel` (Application started at URL **http://localhost:5004/**).
|
5. Run `k kestrel` (Application started at URL **http://localhost:5004/**).
|
||||||
* **[CustomHost]:**
|
* **[CustomHost]:**
|
||||||
6. Run `k run` (This hosts the app in a console application - Application started at URL **http://localhost:5003/**).
|
6. Run `k run` (This hosts the app in a console application - Application started at URL **http://localhost:5003/**).
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace MusicStore.Areas.Admin.Controllers
|
||||||
{
|
{
|
||||||
var cacheKey = GetCacheKey(id);
|
var cacheKey = GetCacheKey(id);
|
||||||
|
|
||||||
var album = await _cache.GetOrSet(GetCacheKey(id), async context =>
|
var album = await _cache.GetOrSet(cacheKey, async context =>
|
||||||
{
|
{
|
||||||
//Remove it from cache if not retrieved in last 10 minutes.
|
//Remove it from cache if not retrieved in last 10 minutes.
|
||||||
context.SetSlidingExpiration(TimeSpan.FromMinutes(10));
|
context.SetSlidingExpiration(TimeSpan.FromMinutes(10));
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ namespace MusicStore.Mocks.MicrosoftAccount
|
||||||
if (formData["redirect_uri"] != null && formData["redirect_uri"].EndsWith("signin-microsoft") &&
|
if (formData["redirect_uri"] != null && formData["redirect_uri"].EndsWith("signin-microsoft") &&
|
||||||
formData["client_id"] == "[ClientId]" && formData["client_secret"] == "[ClientSecret]")
|
formData["client_id"] == "[ClientId]" && formData["client_secret"] == "[ClientSecret]")
|
||||||
{
|
{
|
||||||
System.Console.WriteLine("Handler2");
|
|
||||||
response.Content = new StringContent("{\"token_type\":\"bearer\",\"expires_in\":3600,\"scope\":\"wl.basic\",\"access_token\":\"ValidAccessToken\",\"refresh_token\":\"ValidRefreshToken\",\"authentication_token\":\"ValidAuthenticationToken\"}");
|
response.Content = new StringContent("{\"token_type\":\"bearer\",\"expires_in\":3600,\"scope\":\"wl.basic\",\"access_token\":\"ValidAccessToken\",\"refresh_token\":\"ValidRefreshToken\",\"authentication_token\":\"ValidAuthenticationToken\"}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Http;
|
using Microsoft.AspNet.Http;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
|
@ -48,6 +49,8 @@ namespace MusicStore
|
||||||
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
||||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||||
|
|
||||||
|
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
|
||||||
|
|
||||||
app.UseServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
//Sql client not available on mono
|
//Sql client not available on mono
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
@ -18,7 +17,6 @@ namespace MusicStore.Mocks.Twitter
|
||||||
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var response = new HttpResponseMessage();
|
var response = new HttpResponseMessage();
|
||||||
Console.WriteLine(request.RequestUri.AbsoluteUri);
|
|
||||||
|
|
||||||
if (request.RequestUri.AbsoluteUri.StartsWith("https://api.twitter.com/oauth/access_token"))
|
if (request.RequestUri.AbsoluteUri.StartsWith("https://api.twitter.com/oauth/access_token"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
|
|
@ -92,6 +93,8 @@ namespace MusicStore
|
||||||
//During development use the ErrorPage middleware to display error information in the browser
|
//During development use the ErrorPage middleware to display error information in the browser
|
||||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||||
|
|
||||||
|
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
|
||||||
|
|
||||||
// Add the runtime information page that can be used by developers
|
// Add the runtime information page that can be used by developers
|
||||||
// to see what packages are used by the application
|
// to see what packages are used by the application
|
||||||
// default path is: /runtimeinfo
|
// default path is: /runtimeinfo
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Security.Claims;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.AspNet.Server.WebListener;
|
using Microsoft.AspNet.Server.WebListener;
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
|
|
@ -23,7 +24,7 @@ namespace MusicStore
|
||||||
/// 1. Set the environment variable named SET ASPNET_ENV=NtlmAuthentication
|
/// 1. Set the environment variable named SET ASPNET_ENV=NtlmAuthentication
|
||||||
/// 2. For selfhost based servers pass in a command line variable named --env with this value. Eg:
|
/// 2. For selfhost based servers pass in a command line variable named --env with this value. Eg:
|
||||||
/// "commands": {
|
/// "commands": {
|
||||||
/// "WebListener": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002 --ASPNET_ENV NtlmAuthentication",
|
/// "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002 --ASPNET_ENV NtlmAuthentication",
|
||||||
/// },
|
/// },
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StartupNtlmAuthentication
|
public class StartupNtlmAuthentication
|
||||||
|
|
@ -66,6 +67,8 @@ namespace MusicStore
|
||||||
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
||||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||||
|
|
||||||
|
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
|
||||||
|
|
||||||
app.UseServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add EF services to the services container
|
// Add EF services to the services container
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
"EntityFramework.InMemory": "7.0.0-*", //For Mono
|
"EntityFramework.InMemory": "7.0.0-*", //For Mono
|
||||||
"Kestrel": "1.0.0-*",
|
"Kestrel": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
|
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
|
||||||
|
"Microsoft.AspNet.Diagnostics.Entity": "7.0.0-*",
|
||||||
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*",
|
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-*",
|
||||||
"Microsoft.AspNet.Mvc": "6.0.0-*",
|
"Microsoft.AspNet.Mvc": "6.0.0-*",
|
||||||
"Microsoft.AspNet.Security.Cookies": "1.0.0-*",
|
"Microsoft.AspNet.Security.Cookies": "1.0.0-*",
|
||||||
|
|
@ -28,8 +29,8 @@
|
||||||
"Microsoft.Framework.OptionsModel": "1.0.0-*"
|
"Microsoft.Framework.OptionsModel": "1.0.0-*"
|
||||||
},
|
},
|
||||||
"commands": {
|
"commands": {
|
||||||
"WebListener": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002",
|
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5002",
|
||||||
"Kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004",
|
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004",
|
||||||
"run": "run server.urls=http://localhost:5003"
|
"run": "run server.urls=http://localhost:5003"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
|
|
|
||||||
|
|
@ -252,10 +252,12 @@ namespace E2ETests
|
||||||
{
|
{
|
||||||
Console.WriteLine(string.Format("Executing klr.exe --appbase {0} \"Microsoft.Framework.ApplicationHost\" {1}", startParameters.ApplicationPath, startParameters.ServerType.ToString()));
|
Console.WriteLine(string.Format("Executing klr.exe --appbase {0} \"Microsoft.Framework.ApplicationHost\" {1}", startParameters.ApplicationPath, startParameters.ServerType.ToString()));
|
||||||
|
|
||||||
|
var commandName = startParameters.ServerType == ServerType.WebListener ? "web" : "kestrel";
|
||||||
|
|
||||||
var startInfo = new ProcessStartInfo
|
var startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "klr.exe",
|
FileName = "klr.exe",
|
||||||
Arguments = string.Format("--appbase {0} \"Microsoft.Framework.ApplicationHost\" {1}", startParameters.ApplicationPath, startParameters.ServerType.ToString()),
|
Arguments = string.Format("--appbase {0} \"Microsoft.Framework.ApplicationHost\" {1}", startParameters.ApplicationPath, commandName),
|
||||||
UseShellExecute = true,
|
UseShellExecute = true,
|
||||||
CreateNoWindow = true
|
CreateNoWindow = true
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue