Ejemplo n.º 1
0
        protected void HandleStaticContent(string requestUriPath)
        {
            if (CommonUtility.IsTextConent(_httpProxy.GetContentType(requestUriPath)))
            {
                var responseString = _contentHandler.GetStringContent(requestUriPath);
                if (!string.IsNullOrEmpty(responseString))
                {
                    _httpProxy.SetResponse(CommonConst._200_OK, responseString);
                }
                else
                {
                    _httpProxy.SetResponse(CommonConst._404_RESOURCE_NOT_FOUND);
                }
            }
            else
            {
                var responseData = _contentHandler.GetContent(requestUriPath);
                if (responseData != null)
                {
                    _httpProxy.SetResponse(CommonConst._200_OK, responseData);
                }
                else
                {
                    _httpProxy.SetResponse(CommonConst._404_RESOURCE_NOT_FOUND, responseData);
                }
            }
            _httpProxy.ContentType = _httpProxy.GetContentType(requestUriPath);

            if (ApplicationConfig.StaticContentCache && !CommonUtility.IsServerSidePage(requestUriPath))
            {
                _httpContext.Response.Cache.SetCacheability(HttpCacheability.Public);
                _httpContext.Response.Cache.SetExpires(DateTime.Now.AddDays(10));
                _httpContext.Response.Cache.SetMaxAge(new TimeSpan(10, 0, 0, 0));
            }
            if (ApplicationMode.Maintenance == ApplicationConfig.GetApplicationMode)
            {
                _httpContext.Response.Headers[string.Format("{0}.{1}", CommonConst.CommonField.HTTP_RESPONE_DEBUG_INFO, CommonConst.CommonValue.TIME_SPAN)]      = (DateTime.Now - _initData.InitDateTime).TotalMilliseconds.ToString();
                _httpContext.Response.Headers[string.Format("{0}.{1}", CommonConst.CommonField.HTTP_RESPONE_DEBUG_INFO, CommonConst.CommonField.TRANSACTION_ID)] = _initData.TransactionId;
            }

            RemoveHeaders();
        }