本文整理匯總了C#中System.App.AddUrl方法的典型用法代碼示例。如果您正苦於以下問題:C# App.AddUrl方法的具體用法?C# App.AddUrl怎麽用?C# App.AddUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.App
的用法示例。
在下文中一共展示了App.AddUrl方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
static void Main(string[] args)
{
var app = new App();
// Configure the static URLs
app.AddUrl("/", Pages.Frontpage);
app.AddUrl("/rss-feed.xml", Pages.RssFeed);
app.AddUrl("/archive", Pages.Archive);
// For static pages, you can directly give the path to a template
app.AddUrl(@"/about", "templates/about.html");
// Add a URL pattern with a regular expression for the article pages.
// The expression captures the name of the article so we can access it in Article.View.
app.AddUrlPattern(@"^/article/(?<articleSlug>[\w\-]+)$", Article.View);
// Serve files from the "/static" folder.
// In production use, you should add a rule to your webserver configuration that directly
// serves the static files from this directory, without passing the requests to this app.
app.AddStaticDirectory("static/");
// Set a custom 404 error page
app.NotFoundView = Pages.NotFound;
// Start accepting requests.
// This method never returns!
app.RunTestServer();
}