A few changes with this checkin:
1. Adding scripts to self host & custom host Music store 2. Updating readme 3. Cleanup some helper classes that are not necessary. 4. Adding error page middleware for diagnostics. 5. Flipping the switch to run helios on "K" by default.
This commit is contained in:
parent
fe9770cc80
commit
5eacb62b62
11
README.md
11
README.md
|
|
@ -3,8 +3,13 @@
|
|||
### Run the application:
|
||||
1. Run build.cmd to restore all the necessary packages and generate project files
|
||||
2. Open a command prompt and cd \src\MusicStore\
|
||||
3. Execute CopyAspNetLoader.cmd to copy the AspNet.Loader.dll to the bin directory
|
||||
4. Execute Run.cmd to launch the app on IISExpress.
|
||||
3. [Helios]:
|
||||
4. Execute CopyAspNetLoader.cmd to copy the AspNet.Loader.dll to the bin directory
|
||||
5. Helios.cmd to launch the app on IISExpress.
|
||||
4. [SelfHost]:
|
||||
5. Run Selfhost.cmd (This runs k web) (Note: If your changes to C# files are not picked up in successive builds - try deleting the bin and obj folder)
|
||||
5. [CustomHost]:
|
||||
6. Run CustomHost.cmd (This hosts the app in a console application) (Note: If your changes to C# files are not picked up in successive builds - try deleting the bin and obj folder)
|
||||
|
||||
### Adding a new package:
|
||||
1. Edit the project.json to include the package you want to install
|
||||
|
|
@ -20,4 +25,4 @@
|
|||
|
||||
### Note:
|
||||
1. By default this script starts the application at http://localhost:5001/. Modify Run.cmd if you would like to change the url
|
||||
2. Use Visual studio only for editing & intellisense. Don't try to build or run the app from Visual studio.
|
||||
2. Use Visual studio only for editing & intellisense. Don't try to build or run the app from Visual studio.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Microsoft.AspNet.Mvc;
|
|||
using MusicStore.Models;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MusicStore.Controllers
|
||||
{
|
||||
|
|
@ -28,9 +29,9 @@ namespace MusicStore.Controllers
|
|||
//Bug: Http verbs not available. Also binding to FormCollection is not available.
|
||||
//[HttpPost]
|
||||
//public IActionResult AddressAndPayment(FormCollection values)
|
||||
public IActionResult AddressAndPayment(int workaroundId)
|
||||
public async Task<IActionResult> AddressAndPayment(int workaroundId)
|
||||
{
|
||||
var coll = this.Context.Request.GetFormAsync().Result;
|
||||
var formCollection = await Context.Request.GetFormAsync();
|
||||
|
||||
var order = new Order();
|
||||
//TryUpdateModel(order);
|
||||
|
|
@ -39,7 +40,7 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
//if (string.Equals(values["PromoCode"], PromoCode,
|
||||
// StringComparison.OrdinalIgnoreCase) == false)
|
||||
if (string.Equals(coll.GetValues("PromoCode").FirstOrDefault(), PromoCode,
|
||||
if (string.Equals(formCollection.GetValues("PromoCode").FirstOrDefault(), PromoCode,
|
||||
StringComparison.OrdinalIgnoreCase) == false)
|
||||
{
|
||||
return View(order);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
//Bug: Need method HttpNotFound() on Controller
|
||||
//return HttpNotFound();
|
||||
return this.HttpNotFound();
|
||||
return new HttpStatusCodeResult(404);
|
||||
}
|
||||
return View(album);
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
//Bug: Need method HttpNotFound() on Controller
|
||||
//return HttpNotFound();
|
||||
return this.HttpNotFound();
|
||||
return new HttpStatusCodeResult(404);
|
||||
}
|
||||
//ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId);
|
||||
//ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId);
|
||||
|
|
@ -122,7 +122,7 @@ namespace MusicStore.Controllers
|
|||
if (album == null)
|
||||
{
|
||||
//Bug: Missing Helper
|
||||
return this.HttpNotFound();
|
||||
return new HttpStatusCodeResult(404);
|
||||
}
|
||||
return View(album);
|
||||
}
|
||||
|
|
@ -151,27 +151,4 @@ namespace MusicStore.Controllers
|
|||
// base.Dispose(disposing);
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bug: HttpNotFoundResult not available in Controllers. Work around.
|
||||
/// </summary>
|
||||
public class HttpNotFoundResult : HttpStatusCodeResult
|
||||
{
|
||||
public HttpNotFoundResult()
|
||||
: base(404)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bug: HttpNotFoundResult not available in Controllers. Work around.
|
||||
/// </summary>
|
||||
public static class Extensions
|
||||
{
|
||||
public static IActionResult HttpNotFound(this Controller controller)
|
||||
{
|
||||
return new HttpNotFoundResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
REM Selfhost does not need this bin folder
|
||||
rmdir /S /Q bin
|
||||
|
||||
REM Figure out path to K.cmd
|
||||
|
||||
FOR /F %%j IN ('dir /b /o:-d ..\..\packages\ProjectK*') do (SET K_CMD_PATH=..\..\packages\%%j\tools\k.cmd)
|
||||
echo Found k.cmd at %K_CMD_PATH%. Starting the self host application
|
||||
%K_CMD_PATH% run server.urls=http://localhost:5001
|
||||
|
|
@ -0,0 +1 @@
|
|||
"%ProgramFiles(x86)%\iis Express\iisexpress.exe" /port:5001 /path:"%cd%"
|
||||
|
|
@ -1,30 +1,38 @@
|
|||
{
|
||||
"version": "0.1-alpha-*",
|
||||
"dependencies": {
|
||||
"Helios": "0.1-alpha-098",
|
||||
"Microsoft.AspNet.Abstractions": "0.1-alpha-152",
|
||||
"Microsoft.AspNet.Mvc": "0.1-alpha-296",
|
||||
"Microsoft.AspNet.Razor": "0.1-alpha-136",
|
||||
"Microsoft.AspNet.ConfigurationModel": "0.1-alpha-108",
|
||||
"Microsoft.AspNet.DependencyInjection": "0.1-alpha-159",
|
||||
"Microsoft.AspNet.RequestContainer": "0.1-alpha-124",
|
||||
"Microsoft.AspNet.Routing": "0.1-alpha-100",
|
||||
"Microsoft.AspNet.Mvc.ModelBinding": "0.1-alpha-296",
|
||||
"Microsoft.AspNet.Mvc.Core": "0.1-alpha-296",
|
||||
"Microsoft.AspNet.Mvc.Razor": "0.1-alpha-296",
|
||||
"Microsoft.AspNet.Mvc.Rendering": "0.1-alpha-296",
|
||||
"Microsoft.AspNet.StaticFiles": "0.1-alpha-081",
|
||||
"System.Security.Claims": "0.1-alpha-045",
|
||||
"Microsoft.AspNet.Security.DataProtection": "0.1-alpha-092",
|
||||
"Microsoft.AspNet.Identity": "0.1-alpha-155",
|
||||
"Microsoft.AspNet.Identity.Entity": "0.1-alpha-155",
|
||||
"Microsoft.AspNet.Identity.InMemory": "0.1-alpha-155"
|
||||
"Helios": "0.1-alpha-107",
|
||||
"Microsoft.AspNet.Abstractions": "0.1-alpha-162",
|
||||
"Microsoft.AspNet.Mvc": "0.1-alpha-324",
|
||||
"Microsoft.AspNet.Razor": "0.1-alpha-144",
|
||||
"Microsoft.AspNet.ConfigurationModel": "0.1-alpha-117",
|
||||
"Microsoft.AspNet.DependencyInjection": "0.1-alpha-169",
|
||||
"Microsoft.AspNet.RequestContainer": "0.1-alpha-133",
|
||||
"Microsoft.AspNet.Routing": "0.1-alpha-115",
|
||||
"Microsoft.AspNet.Mvc.ModelBinding": "0.1-alpha-324",
|
||||
"Microsoft.AspNet.Mvc.Core": "0.1-alpha-324",
|
||||
"Microsoft.AspNet.Mvc.Razor": "0.1-alpha-324",
|
||||
"Microsoft.AspNet.Mvc.Rendering": "0.1-alpha-324",
|
||||
"Microsoft.AspNet.StaticFiles": "0.1-alpha-090",
|
||||
"System.Security.Claims": "0.1-alpha-052",
|
||||
"Microsoft.AspNet.Security.DataProtection": "0.1-alpha-100",
|
||||
"Microsoft.AspNet.Identity": "0.1-alpha-164",
|
||||
"Microsoft.AspNet.Identity.Entity": "0.1-alpha-164",
|
||||
"Microsoft.AspNet.Identity.InMemory": "0.1-alpha-164",
|
||||
"Microsoft.Data.Entity": "0.1-alpha-284",
|
||||
"Microsoft.Data.Relational": "0.1-alpha-284",
|
||||
"Microsoft.Data.SqlServer": "0.1-pre-284",
|
||||
"Microsoft.Data.InMemory": "0.1-alpha-284",
|
||||
"Microsoft.AspNet.Diagnostics": "0.1-alpha-025",
|
||||
"Microsoft.AspNet.Hosting": "0.1-alpha-133",
|
||||
"Microsoft.AspNet.Server.WebListener": "0.1-alpha-039"
|
||||
},
|
||||
"configurations": {
|
||||
"net45": {
|
||||
"dependencies": {
|
||||
"System.Runtime": "",
|
||||
"System.ComponentModel.DataAnnotations": ""
|
||||
"System.ComponentModel.DataAnnotations": "",
|
||||
"System.Data": ""
|
||||
}
|
||||
},
|
||||
"k10": {
|
||||
|
|
@ -38,7 +46,7 @@
|
|||
"System.Console": "4.0.0.0",
|
||||
"System.Diagnostics.Debug": "4.0.10.0",
|
||||
"System.Diagnostics.Tools": "4.0.0.0",
|
||||
"Microsoft.ComponentModel.DataAnnotations": "0.1-alpha-032"
|
||||
"Microsoft.ComponentModel.DataAnnotations": "4.0.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
using Microsoft.AspNet.ConfigurationModel;
|
||||
using Microsoft.AspNet.ConfigurationModel.Sources;
|
||||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.AspNet.DependencyInjection.Fallback;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MusicStore
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private readonly IServiceProvider _hostServiceProvider;
|
||||
|
||||
public Program(IServiceProvider hostServiceProvider)
|
||||
{
|
||||
_hostServiceProvider = hostServiceProvider;
|
||||
}
|
||||
|
||||
public Task<int> Main(string[] args)
|
||||
{
|
||||
//Add command line to the configuration source to read command line parameters.
|
||||
var config = new Configuration();
|
||||
config.AddCommandLine(args);
|
||||
|
||||
var serviceCollection = new ServiceCollection();
|
||||
serviceCollection.Add(HostingServices.GetDefaultServices(config));
|
||||
var services = serviceCollection.BuildServiceProvider(_hostServiceProvider);
|
||||
|
||||
var context = new HostingContext()
|
||||
{
|
||||
Services = services,
|
||||
Configuration = config,
|
||||
ServerName = "Microsoft.AspNet.Server.WebListener",
|
||||
ApplicationName = "BugTracker"
|
||||
};
|
||||
|
||||
var engine = services.GetService<IHostingEngine>();
|
||||
if (engine == null)
|
||||
{
|
||||
throw new Exception("TODO: IHostingEngine service not available exception");
|
||||
}
|
||||
|
||||
using (engine.Start(context))
|
||||
{
|
||||
Console.WriteLine("Started the server..");
|
||||
Console.WriteLine("Press any key to stop the server");
|
||||
Console.ReadLine();
|
||||
}
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
REM Selfhost does not need this bin folder
|
||||
rmdir /S /Q bin
|
||||
|
||||
REM Figure out path to K.cmd
|
||||
|
||||
FOR /F %%j IN ('dir /b /o:-d ..\..\packages\ProjectK*') do (SET K_CMD_PATH=..\..\packages\%%j\tools\k.cmd)
|
||||
echo Found k.cmd at %K_CMD_PATH%. Starting the self host application
|
||||
%K_CMD_PATH% web
|
||||
|
|
@ -6,6 +6,7 @@ using Microsoft.AspNet.ConfigurationModel;
|
|||
using Microsoft.AspNet.DependencyInjection;
|
||||
using Microsoft.AspNet.DependencyInjection.Fallback;
|
||||
using Microsoft.AspNet.DependencyInjection.NestedProviders;
|
||||
using Microsoft.AspNet.Diagnostics;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.InMemory;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
|
@ -21,6 +22,16 @@ public class Startup
|
|||
{
|
||||
CreateAdminUser();
|
||||
|
||||
app.UseErrorPage(new ErrorPageOptions()
|
||||
{
|
||||
ShowCookies = true,
|
||||
ShowEnvironment = true,
|
||||
ShowExceptionDetails = true,
|
||||
ShowHeaders = true,
|
||||
ShowQuery = true,
|
||||
ShowSourceCode = true
|
||||
});
|
||||
|
||||
app.UseFileServer();
|
||||
|
||||
var serviceProvider = MvcServices.GetDefaultServices().BuildServiceProvider(app.ServiceProvider);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,13 @@
|
|||
"Microsoft.Data.Entity": "0.1-alpha-*",
|
||||
"Microsoft.Data.Relational": "0.1-alpha-*",
|
||||
"Microsoft.Data.SqlServer": "0.1-pre-*",
|
||||
"Microsoft.Data.InMemory": "0.1-alpha-*"
|
||||
"Microsoft.Data.InMemory": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.Diagnostics": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.Hosting": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.Server.WebListener": "0.1-alpha-*"
|
||||
},
|
||||
"commands": {
|
||||
"web": "Microsoft.AspNet.Hosting server.name=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001"
|
||||
},
|
||||
"configurations": {
|
||||
"net45": {
|
||||
|
|
@ -34,8 +40,8 @@
|
|||
},
|
||||
"k10": {
|
||||
"dependencies": {
|
||||
"System.Collections": "4.0.0.0",
|
||||
"System.Linq": "4.0.0.0",
|
||||
"System.Collections": "4.0.0.0",
|
||||
"System.Linq": "4.0.0.0",
|
||||
"System.Runtime": "4.0.20.0",
|
||||
"System.Dynamic.Runtime": "4.0.0.0",
|
||||
"System.Threading.Tasks": "4.0.0.0",
|
||||
|
|
@ -43,7 +49,7 @@
|
|||
"System.Console": "4.0.0.0",
|
||||
"System.Diagnostics.Debug": "4.0.10.0",
|
||||
"System.Diagnostics.Tools": "4.0.0.0",
|
||||
"Microsoft.ComponentModel.DataAnnotations": "0.1-alpha-*"
|
||||
"Microsoft.ComponentModel.DataAnnotations": "4.0.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
</system.web>
|
||||
|
||||
<appSettings>
|
||||
<add key="K" value="false" />
|
||||
<!-- Change below value to 'false' to run on full desktop -->
|
||||
<add key="K" value="true" />
|
||||
|
||||
<add key="DefaultAdminUsername" value="Administrator" />
|
||||
<add key="DefaultAdminPassword" value="YouShouldChangeThisPassword" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue