1) Isn't it a bad practice to use these attributes on all of my Controllers?
[HandleError] [CompressFilter(Order = 1)]
Compress filter is defined as:
public class CompressFilter : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if ( !AppConfig.IsResponseCompressionEnabled ) {
base.OnActionExecuting(filterContext);
return;
}
HttpRequestBase request = filterContext.HttpContext.Request;
string acceptEncoding = request.Headers["Accept-Encoding"];
if ( string.IsNullOrEmpty(acceptEncoding) ) return;
acceptEncoding = acceptEncoding.ToUpperInvariant();
HttpResponseBase response = filterContext.HttpContext.Response;
if ( acceptEncoding.Contains("GZIP") ) {
response.AppendHeader("Content-encoding", "gzip");
response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
}
else if ( acceptEncoding.Contains("DEFLATE") ) {
response.AppendHeader("Content-encoding", "deflate");
response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
}
}
}
2) What if i need to call some server functions from client, using ajax. Is it good idea, to create one special controller(named ie. "WebServiceController") for such a tasks?