1
votes

I want to display a view after facebook authentication in my application but I'm getting the json response instead the html view, according to the documentation the view resolution is the following:

The resolution order ServiceStack's uses to resolve the appropriate Markdown template to use for rendering HTML output is:

  1. If the Web Service specifies a template (via a customized IHttpResult.TemplateName response) - then a View with that name.
  2. A view with the same name as the Response DTO, looking first in /Views then in /Views/Shared
  3. A view with the same name as the Request DTO, looking first in /Views then in /Views/Shared

these are my DTOs

 public class FacebookRequest{}
 public class FacebookResponse{}

this is my route configuration

Routes.Add<FacebookRequest>("/User/facebook");

my view has the folloing code:

@inherits ViewPage<MyProject.Services.Dto.FacebookResponse>

this is a facebook response

Service method:

 [ClientCanSwapTemplates]
  public FacebookResponse Get(FacebookRequest userRequest)
  {
      return new FacebookResponse();
  }

As far as I understand if I have a view located in the "views" directory with the same responseDTO it should wire the view with the response from the service.

1
I don't get your question clearly but razor.servicestack.net project will help you to understand view things. Please can you pin point the things where you are stuck? - kunjee
Is the name of your view FacebookResponse.cshtml or FacebookResponse.md? Is it located in your /Views or /Views/Shared directory? Your question doesn't state that explicitly. - Pauli Price
@kunjee hi I was getting a json response instead a html view - pedrommuller
@marfarma the files are .cshtml and they are located in a folder named "views" it supposed if I got a responseDTO associated with a viewpage it should pick that up automatically, what I had to do was to define an attribute [DefaultView("name of the view")] explicitly to the view that I needed to render, but I'm still wondering why I had to do that. - pedrommuller
SS uses the exact name of the response DTO class and looks for a view file with that exact name on the filesystem, unless you provide a DefaultView attribute. So, if your view (in your example) wasn't Views/FacebookResponse.cshtml exactly, it won't work. Using the inherits viewpage statement doesn't help SS resolve the view. It's looking for the exact file name in a specific location. I'm not 100% on this - but I seem to recall that it was a case sensitive match too. - Pauli Price

1 Answers

1
votes

Adding comment as answer

SS uses the exact name of the response DTO class and looks for a view file with that exact name on the filesystem, unless you provide a DefaultView attribute. So, if your view (in your example) wasn't Views/FacebookResponse.cshtml exactly, it won't work. Using the inherits viewpage statement doesn't help SS resolve the view. It's looking for the exact file name in a specific location. I'm not 100% on this - but I seem to recall that it was a case sensitive match too.