當前位置: 首頁>>代碼示例>>C#>>正文


C# HttpResponse.SendFailure方法代碼示例

本文整理匯總了C#中System.Web.HttpResponse.SendFailure方法的典型用法代碼示例。如果您正苦於以下問題:C# HttpResponse.SendFailure方法的具體用法?C# HttpResponse.SendFailure怎麽用?C# HttpResponse.SendFailure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.HttpResponse的用法示例。


在下文中一共展示了HttpResponse.SendFailure方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProcessRequestInner


//.........這裏部分代碼省略.........
                // Create a new session
                var session = Session.Create(request, this, new EnvelopeHandlerMulti());

                // Send frame
                DelegateFrame.SendFrame(response, session);
                return;
            }

            // If robots
            if (request.Path.ToUpperInvariant() == "/ROBOTS.TXT") {
                Robots(context);
                return;
            }

            // Check we have WAR
            if (null == HttpRootFile) {
                response.Write("No WAR.");
                return;
            }

            // If needed, upgrade the connection to HTTPS
            if (RequireSecureHttp && !request.IsSecureConnection && string.Compare(request.Url.Host, "localhost", true) != 0) {
                var url = request.Url.ToString();
                url = "https" + url.Substr(url.IndexOf(":"));
                response.Redirect(url);
                return;
            }

            // Find target details
            var path = request.Path == "/" ? "/index.html" : request.Path;

            // Stop hacks
            if (path.IndexOf("..") > -1 || path.IndexOf("//") > -1 || path.IndexOf("\\\\") > -1) {
                response.SendFailure(HttpStatusCode.NotFound, "Denied.");
            }

            // Get content
            byte[] page;
            lock (WebCache) {
                // Read cache
                page = WebCache[path] as byte[];

                // If cache miss..
                if (null == page) {

                    // Open WAR file
                    if (null == HttpRoot) {
                        try {
                            HttpRoot = ZipFile.Read(HttpRootFile.FullName);
                        } catch (Exception ex) {
                            // Log the exception
                            LogException(ex, "Variant-HttpRoot", Ids.System);

                            // Warn users that we're updating
                            response.Write("We're currently updating our content. Hang tight - the site will be back shortly!");
                            return;
                        }

                        if (null == HttpRoot["/index.html"]) {
                            throw new Exception("Missing '/index.html' in WAR");
                        }
                    }

                    // Open file
                    ZipEntry file;
                    if (null == (file = HttpRoot[path])) {
開發者ID:invertedtomato,項目名稱:Amos3,代碼行數:67,代碼來源:Variant.cs


注:本文中的System.Web.HttpResponse.SendFailure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。