public void ProcessRequest()
        {
            var response = requestContext.HttpContext.Response;
            var request  = requestContext.HttpContext.Request;

            if (!CanAccessHud(request))
            {
                response.StatusCode = (int)HttpStatusCode.NotFound;
                throw new HttpException((int)HttpStatusCode.NotFound, "Not found");
            }

            if (request.HttpMethod.Equals("post", StringComparison.OrdinalIgnoreCase))
            {
                ProcessPost();
                return;
            }

            Bundles.AddPageData("data", PageData());
            Bundles.Reference("~/Cassette.Aspnet.Resources");

            var html = Properties.Resources.hud;

            html = html.Replace("$scripts$", Bundles.RenderScripts().ToHtmlString());
            response.ContentType = "text/html";
            response.Write(html);
        }
示例#2
0
        public void ReferencingInlineScriptBundlesMustWork()
        {
            HttpContextBase httpContext = null;

            using (var host = new TestableWebHost("assets", () => httpContext))
            {
                using (var http = new HttpTestHarness(host))
                {
                    httpContext = http.Context.Object;

                    host.Initialize();

                    Bundles.AddPageData("x", new { data = 1 });
                }
            }
        }
示例#3
0
 public void AddPageDataWithDataDictionaryAddsReferenceToPageDataScriptBundle()
 {
     Bundles.AddPageData("content", new Dictionary <string, object>(), "location");
     referenceBuilder.Verify(b => b.Reference(It.Is <Bundle>(bundle => bundle is PageDataScriptBundle), "location"));
 }
示例#4
0
 public void AddPageDataWithDataObjectAddsReferenceToPageDataScriptBundle()
 {
     Bundles.AddPageData("content", new { data = 1 }, "location");
     referenceBuilder.Verify(b => b.Reference(It.Is <Bundle>(bundle => bundle is PageDataScriptBundle), "location"));
 }