jklemmack
jklemmack

Reputation: 3636

ServiceStack Razor not finding right view

I have a ServiceStack site that uses ServiceStack.Razor without issue. I upgraded from 4.0.50 to 5.1.0 - with no other substantive changes - and now the Razor view engine is not rendering for service methods with a DefaultView. If I instead return an HttpResult and set the view that way, it does work. Did the behavior change from 4.x to 5.1, or am I missing something?

Original (works):

    [DefaultView("UploadRetailerReports")]
    public object Get(AdminHome request)
    {
        return new HttpResult()
        {
        };
    }

After (required workaround):

    public object Get(AdminHome request)
    {
        return new HttpResult()
        {
            View = "UploadRetailerReports"
        };
    }

Upvotes: 1

Views: 31

Answers (1)

mythz
mythz

Reputation: 143389

I've tested a [DefaultView] attribute as a class and action attribute in this commit and they're both working as expected and rendering the selected View.

Upvotes: 0

Related Questions