Skip to content

Instantly share code, notes, and snippets.

@ianbattersby
Last active December 22, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianbattersby/6435993 to your computer and use it in GitHub Desktop.
Save ianbattersby/6435993 to your computer and use it in GitHub Desktop.
Example Simple.web w/Razor
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections />
<appSettings>
<add key="webPages:Enabled" value="false" />
<add key="ViewCache:Enabled" value="false" />
<add key="ViewPath:Value" value="Views" />
<add key="ViewRecursiveDiscovery:Enabled" value="true" />
</appSettings>
</configuration>
namespace ConsoleApplication26
{
using System;
using System.Collections.Generic;
using Simple.Web;
using Simple.Web.Behaviors;
internal class Program
{
public static Type[] EnforceReferencesFor = { typeof(Simple.Web.Razor.AmbiguousViewException) };
private static void Main(string[] args)
{
new Simple.Web.Hosting.Self.OwinSelfHost().Run();
}
}
public class IndexModel
{
public string Message { get; set; }
}
[UriTemplate("/")]
public class GetIndex : IGet, IOutput<IEnumerable<IndexModel>>
{
public Status Get()
{
this.Output = new[]
{
new IndexModel { Message = "Hi" },
new IndexModel { Message = "From" },
new IndexModel { Message = "Simple.Web" }
};
return 200;
}
public IEnumerable<IndexModel> Output { get; private set; }
}
}
@handler ConsoleApplication26.GetIndex
<!DOCTYPE html>
<html>
<head>
<title>Test page</title>
</head>
<body>
<div>
@foreach (var item in @Handler.Output)
{
<p>@item.Message</p>
}
</div>
</body>
</html>
@model IEnumerable<ConsoleApplication26.IndexModel>
<!DOCTYPE html>
<html>
<head>
<title>Test page</title>
</head>
<body>
<div>
@foreach (var message in @Model)
{
<p>@message</p>
}
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment