【问题标题】:Is there a way to host Razor pages in console application using ServiceTask?有没有办法使用 ServiceTask 在控制台应用程序中托管 Razor 页面?
【发布时间】:2012-08-15 14:49:23
【问题描述】:

我正在尝试制作一个控制台应用程序来公开 JSON 服务。 此外,我想托管 html 和 js 页面来使用它们。 我将 *.md(甚至 *.htm)文件放入 Views 文件夹,但无法访问它们。

如果我添加一个路由“.Add(”/Test")”(其中 MyMarkdownView : MarkdownViewBase),我什至会得到一个“KeyNotFoundException The given key was not present in the dictionary”。例外。

一般情况下是否可以,或者我应该自己制作服务(类似于https://github.com/jimschubert/blogs/blob/master/2012-07-15/RazorExample/Main.cs)来托管它们?

【问题讨论】:

    标签: razor markdown servicestack


    【解决方案1】:

    您可能对使用嵌入式资源 MVC Razor 视图的Razor Rockstars 控制台应用程序感兴趣,该视图可与(或不与)现有ServiceStack web services 一起使用。

    即示例项目展示了在 ServiceStack 中托管 MVC Razor 页面的 3 种不同方式:

    1. Service/Controller and Model - 使用来自 Web ServiceResponse DTO 作为 视图模型
    2. No Service/Controller - 直接使用 Request DTO 作为视图模型
    3. No Service/Controller or Model - 直接使用动态视图模型

    【讨论】:

      猜你喜欢
      • 2013-05-16
      • 2011-03-07
      • 2016-10-06
      • 2011-02-26
      • 2023-03-15
      • 2010-11-14
      • 1970-01-01
      • 1970-01-01
      • 2021-11-24
      相关资源
      最近更新 更多