에서 최신 버전의 면도기를 사용하고 있습니다. https://github.com/Antaris/RazorEngine면도기 런 컴 파일이 디버그를 허용하지 않습니다
일부 cshtml에 첨부하고 디버깅하고 싶습니다. 내 코드에서
Debugging
One thing you might want to enable is the debugging feature:
config.Debug = true;
When Debug is true you can straight up debug into the generated code. RazorEngine also supports debugging directly into the template files (normally .cshtml files). As as you might see in the above code there is no file to debug into. To provide RazorEngine with the necessary information you need to tell where the file can be found:
string template = "Hello @Model.Name, welcome to RazorEngine!";
string templateFile = "C:/mytemplate.cshtml"
var result =
Engine.Razor.RunCompile(new LoadedTemplateSource(template, templateFile), "templateKey", null, new {
다음
Readme 파일 상태는 내가 설정을 가지고있는
var config = new TemplateServiceConfiguration();
// .. configure your instance
config.Debug = true;
var service = RazorEngineService.Create(config);
Engine.Razor = service;
//string template = "Hello @Model.Name, welcome to RazorEngine!";
string templateFile = "C:/mytemplate.cshtml";
var template = new LoadedTemplateSource("", templateFile);
var result =
Engine.Razor.RunCompile(template, this.Name, null, model);
지금 나는 그것에서 다음과 같이 해당 경로에서 cshtml 파일을 만든 다음. 내가 그것으로 F11 때
@{
var a = 1;
a = a + a;
@a
}
<div>
hi
</div>
하지만 빈 문자열 :( 을 반환받을 그리고 그것은 그냥 단계 :(:(. 어떤 아이디어를 가지고 무엇을 메신저 잘못된 사람을하고
임 확실하지.
는응답 코드는
string templateFile = "C:/mytemplate.cshtml";
StringBuilder sb = new StringBuilder();
using (StreamReader sr = new StreamReader(templateFile))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
sb.AppendLine(line);
}
}
string allines = sb.ToString();
var template = new LoadedTemplateSource(allines, templateFile);
var result =
Engine.Razor.RunCompile(template, this.Name, null, model);
,하지만 당신은'File.ReadAllText (templateFile)와 쉽게 파일의 내용을 읽을 수는' –
하, 즉 그것을하는 더 나은 방법입니다. 왜 내가 그렇게했는지 모르겠다. S. – Spaceman