forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultViewAttribute.cs
More file actions
28 lines (25 loc) · 923 Bytes
/
DefaultViewAttribute.cs
File metadata and controls
28 lines (25 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using ServiceStack.ServiceHost;
namespace ServiceStack.ServiceInterface
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
public class DefaultViewAttribute : RequestFilterAttribute
{
public string View { get; set; }
public string Template { get; set; }
public DefaultViewAttribute() { }
public DefaultViewAttribute(string view) : this(view, null) { }
public DefaultViewAttribute(string view, string template)
{
View = view;
Template = template;
}
public override void Execute(IHttpRequest req, IHttpResponse res, object requestDto)
{
if (!string.IsNullOrEmpty(View))
req.Items["View"] = View;
if (!string.IsNullOrEmpty(Template))
req.Items["Template"] = Template;
}
}
}