当前位置: 首页>>代码示例>>C#>>正文


C# Web.HttpResponseBase类代码示例

本文整理汇总了C#中System.Web.HttpResponseBase的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseBase类的具体用法?C# HttpResponseBase怎么用?C# HttpResponseBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpResponseBase类属于System.Web命名空间,在下文中一共展示了HttpResponseBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetResponse

		/// <summary>
		/// set http response cookies
		/// </summary>
		/// <param name="response"></param>
		/// <param name="companyUserSesson">if null-remove cookie</param>
		public void SetResponse ( HttpResponseBase response , CompanyUserSession companyUserSesson )
		{
			if (companyUserSesson != null)
			{

				if (response.Cookies[SessionIdCookieName] == null)
				{
					HttpCookie sidCookie = new HttpCookie(SessionIdCookieName, companyUserSesson.Sid);
					response.Cookies.Add(sidCookie);
				}
				else
				{
					response.Cookies[SessionIdCookieName].Value = companyUserSesson.Sid;
				}
				if (response.Cookies[UserIdCookieName] == null)
				{
					HttpCookie uIdCookie = new HttpCookie(UserIdCookieName, companyUserSesson.CompanyUserId.ToString());
					response.Cookies.Add(uIdCookie);
				}
				else
				{
					response.Cookies[UserIdCookieName].Value = companyUserSesson.CompanyUserId.ToString();
				}
			}
			else
			{
				HttpCookie uIdCookie = new HttpCookie(UserIdCookieName, "") {Expires = DateTime.Now};
				response.Cookies.Add ( uIdCookie );
				HttpCookie sidCookie = new HttpCookie(SessionIdCookieName, "") {Expires = DateTime.Now};
				response.Cookies.Add ( sidCookie );
			}
		}
开发者ID:alexey-aristov,项目名称:Advertising,代码行数:37,代码来源:AuthProvider.cs

示例2: Context

        protected override void Context()
        {
            AccountService = MockRepository.GenerateStub<IAccountService>();

            Identity = new FakeIdentity(Username);
            _user = new FakePrincipal(Identity, null);

            HttpRequest = MockRepository.GenerateStub<HttpRequestBase>();
            HttpContext = MockRepository.GenerateStub<HttpContextBase>();
            HttpContext.Stub(x => x.Request).Return(HttpRequest);
            HttpContext.User = _user;

            _httpResponse = MockRepository.GenerateStub<HttpResponseBase>();
            _httpResponse.Stub(x => x.Cookies).Return(new HttpCookieCollection());
            HttpContext.Stub(x => x.Response).Return(_httpResponse);

            Logger = MockRepository.GenerateStub<ILogger>();
            WebAuthenticationService = MockRepository.GenerateStub<IWebAuthenticationService>();

            MappingEngine = MockRepository.GenerateStub<IMappingEngine>();
            AccountCreator = MockRepository.GenerateStub<IAccountCreator>();

            AccountController = new AccountController(AccountService, Logger, WebAuthenticationService, MappingEngine, null, AccountCreator);
            AccountController.ControllerContext = new ControllerContext(HttpContext, new RouteData(), AccountController);
        }
开发者ID:AcklenAvenue,项目名称:PRTools,代码行数:25,代码来源:given_an_account_controller_context.cs

示例3: HandleResult

        public bool HandleResult( IResult result, IFormatInfo outputFormat, HttpRequestBase request, HttpResponseBase response )
        {
            response.AddHeader("Accept-Ranges", "bytes");

            Range range;
            if ( !TryGetRequestedRange( request, out range ) )
            {
                return false;
            }

            if (!ValidateIfRangeHeader(request, result))
            {
                return false;
            }

            var offset = range.Start ?? 0;
            var end = range.End.HasValue ? range.End.Value : result.ContentLength - 1;
            var length = end - offset + 1;

            response.AddHeader( "Content-Range", "bytes " + offset + "-" + end + "/" + result.ContentLength );
            response.StatusCode = 206;

            result.Serve( response, offset, length );
            return true;
        }
开发者ID:bmbsqd,项目名称:dynamic-media,代码行数:25,代码来源:BytesRangeResultHandler.cs

示例4: WriteFile

 protected override void WriteFile(HttpResponseBase response)
 {
     using (XmlWriter writer = XmlWriter.Create(response.OutputStream))
     {
         _feed.SaveAsRss20(writer);
     }
 }
开发者ID:inatoff,项目名称:ACTS_Site,代码行数:7,代码来源:RssResult.cs

示例5: SerializeData

        protected virtual void SerializeData(HttpResponseBase response)
        {
            if (ErrorMessages.Any())
            {
                var originalData = Data;
                Data = new
                {
                    Success = false,
                    OriginalData = originalData,
                    ErrorMessage = string.Join("\n", ErrorMessages),
                    ErrorMessages = ErrorMessages.ToArray()
                };

                response.StatusCode = StatusCode;
            }

            var settings = new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver(),
                Converters = new JsonConverter[]
                {
                    new StringEnumConverter(),
                },
            };

            response.Write(JsonConvert.SerializeObject(Data, settings));
        }
开发者ID:andrewreyes,项目名称:NiftyMvcHelpers,代码行数:27,代码来源:StandardJsonResult.cs

示例6: PrepareExcel

        /// <summary>
        /// Prepares the excel.
        /// </summary>
        /// <param name="dataTable">The data table.</param>
        /// <param name="reportName">Name of the report.</param>
        /// <param name="reportTitle">The report title.</param>
        /// <param name="responseBase">The response base.</param>
        /// <param name="serverBase">The server base.</param>
        public void PrepareExcel(DataTable dataTable, string reportName, string reportTitle, HttpResponseBase responseBase, HttpServerUtilityBase serverBase)
        {
            this.response = responseBase;
            this.server = serverBase;

            this.GenerateTable(dataTable, reportName, reportTitle);
        }
开发者ID:JaipurAnkita,项目名称:mastercode,代码行数:15,代码来源:ExcelProvider.cs

示例7: CacheLongTime

 void CacheLongTime(HttpResponseBase response, string actualETag)
 {
     response.Cache.SetCacheability(HttpCacheability.Public);
     response.Cache.SetExpires(DateTime.UtcNow.AddYears(1));
     response.Cache.SetMaxAge(new TimeSpan(365, 0, 0, 0));
     response.Cache.SetETag(actualETag);
 }
开发者ID:justanswer,项目名称:cassette,代码行数:7,代码来源:AssetRequestHandler.cs

示例8: FillResponse

 public void FillResponse(HttpResponseBase response, HttpContextBase context)
 {
     var trigger = context.Request.Params["trigger"];
     var jobGroup = context.Request.Params["group"];
     _schedulerProvider.Scheduler.PauseTrigger(trigger, jobGroup);
     response.Redirect(context.Request.UrlReferrer.OriginalString);
 }
开发者ID:JustAGhosT,项目名称:CrystalQuartz,代码行数:7,代码来源:PauseTriggerFiller.cs

示例9: DoAction

        protected override void DoAction(HttpResponseBase response, HttpContextBase context)
        {
            var jobName = context.Request.Params["job"];
            var jobGroup = context.Request.Params["group"];

            _schedulerProvider.Scheduler.PauseJob(new JobKey(jobName, jobGroup));
        }
开发者ID:serbrech,项目名称:CrystalQuartz,代码行数:7,代码来源:PauseJobFiller.cs

示例10: GetFavs

        public static Dictionary<string, string> GetFavs(HttpResponseBase Response)
        {
            Dictionary<string, string> favs = new Dictionary<string, string>();
            HttpCookie testCookie = new HttpCookie("favorites");
            testCookie.Expires = DateTime.Now.AddHours(24);
            testCookie.Name = "favorites";
            testCookie.Values.Add("linkText", "linkUrl");
            testCookie.Values.Add("linkText2", "linkUrl2");
            Response.Cookies.Add(testCookie);

            System.Web.HttpCookie cookieFavs = Response.Cookies.Get("favorites");

            if (cookieFavs.Values.Count > 0)
            {
                NameValueCollection nvc = cookieFavs.Values;
                for (int i = 0; i < nvc.Count; i++ )
                {
                    string key = nvc.Keys[i];
                    string value = nvc[i];
                    favs.Add(Resources.Localizer.GetString("Resources.Shared.Nav", key, key), value);
                }
            }
            else // get from db
            {

            }

            return favs;
        }
开发者ID:ManEx,项目名称:WebManex,代码行数:29,代码来源:Favorites.cs

示例11: DoAction

        protected override void DoAction(HttpResponseBase response, HttpContextBase context)
        {
            var trigger = context.Request.Params["trigger"];
            var jobGroup = context.Request.Params["group"];

            _schedulerProvider.Scheduler.ResumeTrigger(new TriggerKey(trigger, jobGroup));
        }
开发者ID:JustAGhosT,项目名称:CrystalQuartz,代码行数:7,代码来源:ResumeTriggerFiller.cs

示例12: WriteFile

 protected override void WriteFile(HttpResponseBase response)
 {
     using (XmlWriter writer = XmlWriter.Create(response.OutputStream))
     {
         _Feed.GetRss20Formatter().WriteTo(writer);
     }
 }
开发者ID:okfurs,项目名称:okfurs.com,代码行数:7,代码来源:RssResult.cs

示例13: XrcResponse

        public XrcResponse(Stream stream, HttpResponseBase parentResponse = null)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            _innerResponse = parentResponse;

            _isStreamOwner = true;
            if (_innerResponse == null)
            {
                _cookies = new HttpCookieCollection();
                _statusCode = (int)HttpStatusCode.OK;
                _contentEncoding = Encoding.UTF8;
                _contentType = "text/html; charset=UTF-8";
                _redirectLocation = null;
                _statusDescription = null;
                _outputStream = stream;
                _output = new StreamWriter(stream, _contentEncoding);
            }
            else
            {
                _cookies = _innerResponse.Cookies;
                _statusCode = (int)HttpStatusCode.OK;
                _contentEncoding = _innerResponse.ContentEncoding;
                _contentType = _innerResponse.ContentType;
                _redirectLocation = null;
                _statusDescription = null;
                _outputStream = stream;
                _output = new StreamWriter(stream, _contentEncoding);
            }
        }
开发者ID:davideicardi,项目名称:xrc,代码行数:31,代码来源:XrcResponse.cs

示例14: ChooseSuitableCompression

        public static void ChooseSuitableCompression(NameValueCollection requestHeaders, HttpResponseBase response)
        {
            if (requestHeaders == null) throw new ArgumentNullException(nameof(requestHeaders));
            if (response == null) throw new ArgumentNullException(nameof(response));


            /// load encodings from header
            QValueList encodings = new QValueList(requestHeaders[ACCEPT_ENCODING_HEADER]);

            /// get the types we can handle, can be accepted and
            /// in the defined client preference
            QValue preferred = encodings.FindPreferred("gzip", "deflate", "identity");

            /// if none of the preferred values were found, but the
            /// client can accept wildcard encodings, we'll default
            /// to Gzip.
            if (preferred.IsEmpty && encodings.AcceptWildcard && encodings.Find("gzip").IsEmpty)
                preferred = new QValue("gzip");

            // handle the preferred encoding
            switch (preferred.Name)
            {
                case "gzip":
                    response.AppendHeader(CONTENT_ENCODING_HEADER, "gzip");
                    response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
                    break;
                case "deflate":
                    response.AppendHeader(CONTENT_ENCODING_HEADER, "deflate");
                    response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
                    break;
                case "identity":
                default:
                    break;
            }
        }
开发者ID:Geta,项目名称:SEO.Sitemaps,代码行数:35,代码来源:CompressionHandler.cs

示例15: Restore

		public static void Restore(HttpRequestBase request, HttpResponseBase response)
		{
			string serverHash = request.QueryString[queryStringName];

			if (serverHash != null)
			{
				string cookieHeader = request.Headers["Cookie"];
				string cookieValue = cookieName + "=" + serverHash;

				// Modifying request.Cookies doesn't work

				if (cookieHeader != null)
				{
					if (cookieHeader.Contains(cookieName + "="))
					{
						cookieHeader = regex.Replace(cookieHeader, cookieValue + ";");
					}
					else
					{
						cookieHeader += "; " + cookieValue;
					}

					request.Headers["Cookie"] = cookieHeader;
				}
				else
				{
					request.Headers.Add("Cookie", cookieValue);
				}

				// response.Cookies also updates request.Cookies, which may have other implications, so we set the raw cookie
				response.Headers.Add("Set-Cookie", cookieName + "=" + serverHash + ";Path=" + request.ApplicationPath + ";Domain=" + request.Url.Host);
			}
		}
开发者ID:envoyat,项目名称:Envoy.ArrCookieRestorer,代码行数:33,代码来源:ArrCookieRestorerModule.cs


注:本文中的System.Web.HttpResponseBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。