Changes to let Net45 sample run over Owin

This commit is contained in:
Pranav K 2014-01-29 19:10:00 -08:00
parent a6393e77ab
commit 85a25685d2
3 changed files with 31 additions and 5 deletions

View File

@ -0,0 +1,22 @@
#if NET45
using System;
using Microsoft.Owin.Hosting;
namespace MvcSample
{
public class Program
{
const string baseUrl = "http://localhost:9001/";
public static void Main()
{
using (WebApp.Start<Startup>(new StartOptions(baseUrl)))
{
Console.WriteLine("Listening at {0}", baseUrl);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
}
}
#endif

View File

@ -1,15 +1,12 @@
#if NET45
using System;
using System.Threading.Tasks;
using System.IO;
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Razor;
using Microsoft.AspNet.Mvc.Routing;
using Microsoft.Owin;
using Microsoft.Owin.FileSystems;
using Owin;
[assembly: OwinStartup(typeof(MvcSample.Startup))]
namespace MvcSample
{
public class Startup
@ -20,7 +17,12 @@ namespace MvcSample
var serviceProvider = MvcServices.Create();
string appRoot = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
// HACK to determine app root.
string appRoot = Environment.CurrentDirectory;
while (!String.IsNullOrEmpty(appRoot) && !appRoot.TrimEnd(Path.DirectorySeparatorChar).EndsWith("MvcSample"))
{
appRoot = Path.GetDirectoryName(appRoot);
}
serviceProvider.AddInstance<IFileSystem>(new PhysicalFileSystem(appRoot));
serviceProvider.Add<IVirtualFileSystem, VirtualFileSystem>();

View File

@ -15,6 +15,8 @@
"Owin": "1.0",
"Microsoft.Owin": "2.1.0",
"Microsoft.Owin.Diagnostics": "2.1.0",
"Microsoft.Owin.Hosting": "2.1.0",
"Microsoft.Owin.Host.HttpListener": "2.1.0",
"Microsoft.AspNet.Abstractions.Owin": "0.1-alpha-*"
}
},