本文整理汇总了C#中System.App.AddStringView方法的典型用法代码示例。如果您正苦于以下问题:C# App.AddStringView方法的具体用法?C# App.AddStringView怎么用?C# App.AddStringView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.App
的用法示例。
在下文中一共展示了App.AddStringView方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// Create a simple web app and serve content on to URLs.
var app = new App();
// Define the URL patterns to respond to incoming requests.
// Any request that does not match one of these patterns will
// be served by app.NotFoundView, which defaults to a simple
// 404 message.
// Easiest way to respond to a request: return a string
app.AddStringView("^/$", (request) => "Hello World");
// More complex response, see below
app.AddStringView("^/info$", InfoView);
// Start listening for HTTP requests. Default port is 8080.
// This method does never return!
app.RunHttpServer();
// Now you should be able to visit me in your browser on http://localhost:8080
}