In the documentation https://sharpscript.net/docs/sharp-pages#view-pages is specified that automatically a match is found on Request/Response DTO, but what should be returned from the service to return the view based on the match?
return new HttpResult(responseModel);
is not returning the view found at /Views/{RequestDTO}.html.
Thanks
mythz
April 19, 2020, 6:56pm
2
Please provide a link to a GitHub repro, just tried this and it works:
$ x new script ProjectName
Added /wwwroot/Views/Hello.html
<h1>Hello Page</h1>
Result: {{model.Result}}!
Changed MyServices
to return the Response DTO within a HttpResult
:
public class MyServices : Service
{
public object Any(Hello request) =>
new HttpResult(new HelloResponse {Result=$"Hello, {request.Name}!"});
}
Called https://localhost:5001/hello/world and still works:
Done! see GitHub - mdissel/ServiceStack_TemplateViewPage
Still not returning the page. I’ve tried:
//return new HttpResult(new DatabaseResponse { DatabaseUrl = $"Database: {request.Name}!" });
return new DatabaseResponse { DatabaseUrl = $"Database: {request.Name}!" };
This is my result:
mythz
April 19, 2020, 7:45pm
4
The file name needs to match the Request DTO exactly, e.g. /Views/Database.html
not the user-defined route /database
.
1 Like
Aha! Solved! May i suggest a case-insensitive match?
mythz
April 19, 2020, 8:01pm
6
No, all behavior should work identically across VFS Providers, Operating Systems, etc.
ok, but routes are case-insensitive…
mythz
April 19, 2020, 8:10pm
8
and doesn’t use VFS providers or are OS dependent.