servicestack Razor view with request and response DTO

Posted by user7398 on Stack Overflow See other posts from Stack Overflow or by user7398
Published on 2012-11-07T04:33:36Z Indexed on 2012/11/07 5:00 UTC
Read the original article Hit count: 207

Filed under:

I'm having a go with the razor functionality in service stack. I have a razor cshtml view working for one of my response DTO's.

I need to access some values from the request DTO in the razor view that have been filled in from some fields from the REST route, so i can construct a url to put into the response html page and also label some form labels.

Is there anyway of doing this? I don't want to duplicate the property from the request DTO into the response DTO just for this html view. Because i'm trying to emulate an existing REST service of another product, i do not want to emit extra data just for the html view.

eg http://localhost/rest/{Name}/details/{Id}

eg

    @inherits ViewPage<DetailsResponse>
   @{

        ViewBag.Title = "todo title";
        Layout = "HtmlReport";
   }

this needs to come from the request dto NOT @Model

<a href="/rest/@Model.Name">link to user</a>
<a href="/rest/@Model.Name/details/@Model.Id">link to user details</a>

© Stack Overflow or respective owner

Related posts about servicestack