Files
document-server-integration/web/documentserver-example/csharp-mvc/Helpers/Utils.cs
2021-04-20 17:33:49 +03:00

23 lines
746 B
C#

using System.Web;
namespace OnlineEditorsExampleMVC.Helpers
{
public static class Utils
{
// get the request header or return the default one
public static string GetOrDefault(this HttpRequest request, string header, string def)
{
var value = request[header];
if (value != null) return value;
return def;
}
// get a cookie from the cookie collection or return the default one
public static string GetOrDefault(this HttpCookieCollection cookies, string cookie, string def)
{
var cook = cookies[cookie];
if (cook != null && !string.IsNullOrEmpty(cook.Value)) return cook.Value;
return def;
}
}
}