Is there a way to host Razor pages in console application using ServiceTask?

我是研究僧i 提交于 2019-12-03 21:48:52

问题


I'm trying to make a console application to expose JSON services. In addition I'd like to host html and js pages to use them. I put the *.md (even *.htm) files into Views folder, but I can't reach them.

If I add a route ".Add("/Test")" (where MyMarkdownView : MarkdownViewBase), i even get a "KeyNotFoundException The given key was not present in the dictionary." exception.

Is it generally possible, or I should make my own service (similar to https://github.com/jimschubert/blogs/blob/master/2012-07-15/RazorExample/Main.cs) to host them?


回答1:


You might be interested in the Razor Rockstars Console Application that uses embedded resource MVC Razor views that work with (or without) existing ServiceStack web services.

i.e. the example project shows the 3 different ways to host MVC Razor pages in ServiceStack:

  1. Service/Controller and Model - Using the Response DTO from the Web Service as a view model
  2. No Service/Controller - Directly using the Request DTO as the view model
  3. No Service/Controller or Model - Directly by using a dynamic view model


来源:https://stackoverflow.com/questions/11971576/is-there-a-way-to-host-razor-pages-in-console-application-using-servicetask

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