ServiceStack razor default page

拈花ヽ惹草 提交于 2019-11-27 07:52:44

In ServiceStack:

  • Razor Pages that exist within the /Views/ folder are called View Pages
  • Razor Pages that exist anywhere else are called Content Pages

The difference between them is that View Pages are Razor views that are used to provide the HTML representations (aka views) for services in much the same way View Pages work for MVC Controllers.

View Pages cannot be called directly, that's the role of Content Pages, which can only be called directly, i.e. outside the context of a service (or redirected to, from a service).

In Razor Rockstars, examples of Content Pages include:

Whereas examples of View Pages include:

Default Pages

For Content Pages the default.cshtml is the index page for a folder. So to set a default page for the root / path, create a /default.cshtml page. An example of this is /default.cshtml home page used in the Reusability demo.

If you want to use a view page as the Home page, you can set the default redirect to it by adding the AppHost config:

SetConfig(new HostConfig { 
   DefaultRedirectPath = "/home"
});

Which would call a service matching the /home route that will use the most appropriate View Page based on the rules laid out in the Razor Rockstars page.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!