#sharp viewpage return template based on requestdto typename

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

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:

image

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:

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?

No, all behavior should work identically across VFS Providers, Operating Systems, etc.

ok, but routes are case-insensitive…

and doesn’t use VFS providers or are OS dependent.