예제 #1
1
		/// <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 );
			}
		}
        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;
        }
        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);
        }
예제 #4
0
 public ResponseCaptureHelper(HttpResponseBase response)
 {
     _response = response;
     _originalWriter = response.Output;
     _localWriter = new StringWriter();
     response.Output = _localWriter;
 }
        // Adds do-not-cache headers to the specified HTTP response (which is expected to result in a file-save
        // operation by the browser) in such a way that the IE browser is still able to save the file.
        // (TODO: if we have more file-save action results than just CsvActionResult, this method can be lifted to
        // a common location and be used by all of them.)
        private static void AddDoNotCacheHeadersToFileSaveResponse(HttpResponseBase response, HttpRequestBase request)
        {
            // Get the browser's internal identifier (from .NET browser definition file).
            var browserId = request.Browser.Id;

            // Detect if the browser is a problem version of IE (= IE 7 and 8; IE 6 and lower aren't supported by this
            // website).
            var problemIEVersion = false;
            if ((browserId.Equals("IE7", StringComparison.OrdinalIgnoreCase)) ||
                (browserId.Equals("IE8", StringComparison.OrdinalIgnoreCase)))
            {
                problemIEVersion = true;
            }

            // Add do-not-cache response headers.
            if (!problemIEVersion)
            {
                // Add the website's standard do-not-cache headers.
                NoCacheAttribute.AddResponseHeaders(response);
            }
            else
            {
                // For problem IE versions...   reference: http://stackoverflow.com/a/5084395
                response.AppendHeader("Last-Modified",
                    DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture)); // RFC 1123 format
                response.AppendHeader("Expires", "-1");
                response.AppendHeader("Cache-Control", "must-revalidate, private");
                response.AppendHeader("Vary", "*");
            }
        }
        public BootStrapModal(HttpResponseBase httpResponse)
        {
            if (httpResponse == null)
                throw new ArgumentNullException("httpResponse");

            this._writer = httpResponse.Output;
        }
        /// <summary>
        /// Sets the cache headers for the HTTP response given <see cref="settings" />.
        /// </summary>
        /// <param name="response">The HTTP response.</param>
        /// <param name="settings">The cache settings.</param>
        public void SetCacheHeaders(HttpResponseBase response, CacheSettings settings)
        {
            var cacheability = HttpCacheability.NoCache;

            switch (settings.Location)
            {
                case OutputCacheLocation.Any:
                case OutputCacheLocation.Downstream:
                    cacheability = HttpCacheability.Public;
                    break;
                case OutputCacheLocation.Client:
                case OutputCacheLocation.ServerAndClient:
                    cacheability = HttpCacheability.Private;
                    break;                    
            }

            response.Cache.SetCacheability(cacheability);

            if (cacheability != HttpCacheability.NoCache)
            {
                response.Cache.SetExpires(DateTime.Now.AddSeconds(settings.Duration));
                response.Cache.SetMaxAge(new TimeSpan(0, 0, settings.Duration));
            }

            if (settings.NoStore)
            {
                response.Cache.SetNoStore();
            }
        }
        public void SendHeaders(HttpResponseBase response, ResponseCompressionType compressionType, IEntity entity)
        {
            //Data must be in uncompressed format when responding partially
            if (entity.CompressionType != ResponseCompressionType.None)
            {
                //TODO: perhaps we could uncompress object, but for now we don't worry about it
                throw new Exception("Cannot do a partial response on compressed data");
            }

            HttpResponseHeaderHelper.SetContentEncoding(response, compressionType);

            switch (compressionType)
            {
                case ResponseCompressionType.None:
                    var contentLength = Range.EndRange - Range.StartRange + 1;
                    HttpResponseHeaderHelper.AppendHeader(response, HttpHeaderContentLength, contentLength.ToString());
                    break;
                case ResponseCompressionType.GZip:
                    response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
                    //This means that the output stream will be chunked, so we don't have to worry about content length
                    break;
                case ResponseCompressionType.Deflate:
                    response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
                    //This means that the output stream will be chunked, so we don't have to worry about content length
                    break;
            }

            response.ContentType = entity.ContentType;
            HttpResponseHeaderHelper.AppendHeader(response, HttpHeaderContentRange, Bytes + " " + Range.StartRange + "-" + Range.EndRange + "/" + entity.ContentLength);
        }
예제 #9
0
        /// <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);
        }
예제 #10
0
 protected override void WriteFile(HttpResponseBase response)
 {
     using (XmlWriter writer = XmlWriter.Create(response.OutputStream))
     {
         _Feed.GetRss20Formatter().WriteTo(writer);
     }
 }
예제 #11
0
 private static void SetCookie(HttpResponseBase response, string language)
 {
     response.Cookies.Add(new HttpCookie(CookieName, language)
                              {
                                  Expires = DateTime.Now.AddYears(1),
                              });
 }
예제 #12
0
파일: Favorites.cs 프로젝트: ManEx/WebManex
        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;
        }
예제 #13
0
        /// <summary>
        /// Prepares the excel.
        /// </summary>
        /// <param name="dataSet">The data set.</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>
        /// <param name="voyageIds">The voyage ids.</param>
        public void PrepareExcel(DataSet dataSet, string reportName, string reportTitle, HttpResponseBase responseBase, HttpServerUtilityBase serverBase, string voyageIds)
        {
            this.response = responseBase;
            this.server = serverBase;

            this.GenerateGuestReconciliationTable(dataSet, reportName, reportTitle, voyageIds);
        }
		public virtual void Execute(HttpResponseBase response)
		{
			response.StatusCode = 200;
			response.ContentType = "text/html";

			var masterControls = new List<IControlPanelControl>();

			masterControls.AddRange(CreateHeaderControls(_securityState));
			
			masterControls.AddRange(_controls);

			masterControls.AddRange(CreateFooterControls());

			using (var writer = new HtmlTextWriter(response.Output))
			{
				// this securitydisabler allows the control panel to execute unfettered when debug compilation is enabled but you are not signed into Sitecore
				using (new SecurityDisabler())
				{
					foreach (var control in masterControls)
						control.Render(writer);
				}
			}

			response.End();
		}
 public PlaceholderReplacingResponseFilter(HttpResponseBase response, IPlaceholderTracker placeholderTracker)
 {
     this.response = response;
     this.placeholderTracker = placeholderTracker;
     outputStream = response.Filter;
     htmlBuffer = new StringBuilder();
 }
예제 #16
0
 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);
 }
예제 #17
0
        public void Apply(HttpResponseBase response)
        {
            if(response == null)
            {
                throw new ArgumentException("response can't be null");
            }

            response.Cache.SetCacheability(Cacheability);

            if (HttpStatusCode == HttpStatusCode.SeeOther || Location != null)
            {
                if (Location == null)
                {
                    throw new InvalidOperationException("Missing Location on redirect.");
                }
                if (HttpStatusCode != HttpStatusCode.SeeOther)
                {
                    throw new InvalidOperationException("Invalid HttpStatusCode for redirect, but Location is specified");
                }

                response.Redirect(Location.ToString());
            }

            response.StatusCode = (int)HttpStatusCode;
        }
        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));
        }
예제 #19
0
        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;
            }
        }
예제 #20
0
        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);
            }
        }
		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);
			}
		}
예제 #22
0
 protected override void WriteFile(HttpResponseBase response)
 {
     using (XmlWriter writer = XmlWriter.Create(response.OutputStream))
     {
         _feed.SaveAsRss20(writer);
     }
 }
예제 #23
0
 public static bool IsFileFromCache(FileInfo info, HttpRequestBase request, HttpResponseBase response)
 {
     DateTime updated = info.LastWriteTimeUtc;
     string filename = info.Name;
     DateTime modifyDate;
     if (!DateTime.TryParse(request.Headers["If-Modified-Since"], out modifyDate))
     {
         modifyDate = DateTime.UtcNow;
     }
     string eTag = GetFileETag(filename, updated);            
     if (!IsFileModified(updated, eTag, request))
     {
         response.StatusCode = (int)System.Net.HttpStatusCode.NotModified;
         response.StatusDescription = "Not Modified";
         response.AddHeader("Content-Length", "0");
         response.Cache.SetCacheability(HttpCacheability.Public);
         response.Cache.SetLastModified(updated);
         response.Cache.SetETag(eTag);
         return true;
     }
     else
     {
         response.Cache.SetAllowResponseInBrowserHistory(true);
         response.Cache.SetCacheability(HttpCacheability.Public);
         response.Cache.SetLastModified(updated);
         response.Cache.SetETag(eTag);
         return false;
     }
 }
        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));
        }
예제 #25
0
        void SendAsset(HttpRequestBase request, HttpResponseBase response, Bundle bundle, IAsset asset)
        {
            response.ContentType = bundle.ContentType;

            var actualETag = "\"" + asset.Hash.ToHexString() + "\"";
            if(request.RawUrl.Contains(asset.Hash.ToHexString())) {
                CacheLongTime(response, actualETag);
            }
            else {
                NoCache(response);
            }

            var givenETag = request.Headers["If-None-Match"];
            if (!disableHashCheck && givenETag == actualETag)
            {
                SendNotModified(response);
            }
            else
            {
                using (var stream = asset.OpenStream())
                {
                    stream.CopyTo(response.OutputStream);
                }
            }
        }
    internal static string BuildManifestResponse(HttpResponseBase Response, TylerUI.AppCacheModel model)
    {
      Response.ContentType = "text/cache-manifest";
      Response.Cache.SetCacheability(HttpCacheability.NoCache);
      Response.Cache.SetExpires(DateTime.MinValue);
      //mvc is adding a blank line on the page, so don't use cshtml for this, just build a string
      //return View("~/Views/Shared/_TylerUiAppManifest.cshtml", model);

      var sb = new StringBuilder();
      sb.AppendLine("CACHE MANIFEST");

      sb.AppendLine(String.Empty);
      sb.Append("# Server Assembly Version: ");
      sb.AppendLine(model.AssemblyVersion);

      sb.AppendLine(String.Empty);
      sb.AppendLine("NETWORK:");
      sb.AppendLine("*");

      sb.AppendLine(String.Empty);
      sb.AppendLine("CACHE:");
      foreach (string cacheItem in model.CacheCollection)
      {
        sb.AppendLine(cacheItem);
      }

      return sb.ToString();
    }
예제 #27
0
        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));
        }
예제 #28
0
 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);
 }
 public static void SavePreferredCulture(HttpResponseBase response, String language,
                                     Int32 expireDays = 1)
 {
     var cookie = new HttpCookie(CookieName) { Expires = DateTime.Now.AddDays(expireDays) };
     cookie.Values[CookieLangEntry] = language;
     response.Cookies.Add(cookie);
 }
예제 #30
0
        public void Apply(HttpResponseBase response)
        {
            if(response == null)
            {
                throw new ArgumentNullException("response");
            }

            response.Cache.SetCacheability(Cacheability);

            if (HttpStatusCode == HttpStatusCode.SeeOther || Location != null)
            {
                if (Location == null)
                {
                    throw new InvalidOperationException("Missing Location on redirect.");
                }
                if (HttpStatusCode != HttpStatusCode.SeeOther)
                {
                    throw new InvalidOperationException("Invalid HttpStatusCode for redirect, but Location is specified");
                }

                response.Redirect(Location.ToString());
            }
            else
            {
                response.StatusCode = (int)HttpStatusCode;
                response.ContentType = ContentType;
                response.Write(Content);

                response.End();
            }
        }
예제 #31
0
 public static void ClearCookie(System.Web.HttpResponseBase response, string cookieName, string cookieValue)
 {
     if (response.Cookies.AllKeys.Contains(cookieName))
     {
         response.Cookies[cookieName].Value   = cookieValue;
         response.Cookies[cookieName].Expires = DateTime.UtcNow.AddDays(-1);
     }
 }
예제 #32
0
 protected override void WriteFile(System.Web.HttpResponseBase response)
 {
     if (fileContents == null)
     {
         throw new ArgumentNullException("fileContents");
     }
     response.OutputStream.Write(this.fileContents, 0, this.fileContents.Length);
 }
예제 #33
0
        /// <summary>
        /// Write exception to output message
        /// </summary>
        public async Task WriteExceptionAsync(HttpResponse httpResponse, Exception ex)
        {
            var webx        = WebSyncException.GetWebSyncException(ex);
            var webXMessage = JsonConvert.SerializeObject(webx);

            httpResponse.StatusCode    = StatusCodes.Status400BadRequest;
            httpResponse.ContentLength = webXMessage.Length;
            await httpResponse.WriteAsync(webXMessage);
        }
예제 #34
0
    public static void SetCookie(this System.Web.HttpResponseBase response, string name, string value, DateTime?expires = null, string path = "/")
    {
        var cookie = new System.Web.HttpCookie(name, value);

        if (expires.HasValue)
        {
            cookie.Expires = expires.Value;
        }
        cookie.Path = path;
        response.SetCookie(cookie);
    }
예제 #35
0
 public static void UpdateCookie(System.Web.HttpResponseBase response, string cookieName, string cookieValue)
 {
     if (response.Cookies.AllKeys.Contains(cookieName))
     {
         response.Cookies[cookieName].Value = cookieValue;
     }
     else
     {
         response.Cookies.Add(new HttpCookie(cookieName, cookieValue));
     }
 }
예제 #36
0
    public override void ExecuteResult(ControllerContext context)
    {
        System.Web.HttpResponseBase response = context.HttpContext.Response;
        System.Web.HttpRequestBase  request  = context.HttpContext.Request;
        string url = request.Url.OriginalString;

        ViewData["RequestedUrl"] = url;
        ViewData["ReferrerUrl"]  = (request.UrlReferrer != null && request.UrlReferrer.OriginalString != url) ? request.UrlReferrer.OriginalString : null;
        response.StatusCode      = 404;

        // Prevent IIS7 from overwriting our error page!
        response.TrySkipIisCustomErrors = true;
        base.ExecuteResult(context);
    }
예제 #37
0
        /// <summary>
        /// Write exception to output message
        /// </summary>
        public async Task WriteExceptionAsync(HttpResponse httpResponse, Exception ex)
        {
            // Check if it's an unknwon error, not managed (yet)
            if (!(ex is SyncException syncException))
            {
                syncException = new SyncException(ex.Message, SyncStage.None, this.LocalProvider.ProviderTypeName, SyncExceptionType.Unknown);
            }

            var webXMessage = JsonConvert.SerializeObject(syncException);

            httpResponse.StatusCode    = StatusCodes.Status400BadRequest;
            httpResponse.ContentLength = webXMessage.Length;
            await httpResponse.WriteAsync(webXMessage);
        }
예제 #38
0
        public void Logout(HttpRequestBase request, System.Web.HttpResponseBase response, System.Web.HttpSessionStateBase session)
        {
            //HttpCookie myCookie = new HttpCookie("rfs.username");
            //myCookie = Request.Cookies["rfs.username"];
            //if (myCookie != null)
            //{
            //    Session[myCookie.Value] = "";
            //}

            //HttpCookie currentUserCookie = Request.Cookies["rfs.username"];
            //Response.Cookies.Remove("rfs.username");
            //if (currentUserCookie != null)
            //{
            //    currentUserCookie.Expires = DateTime.Now.AddDays(-10);
            //    currentUserCookie.Value = null;
            //    Response.SetCookie(currentUserCookie);
            //}
        }
예제 #39
0
        public void Logout(System.Web.HttpRequestBase request, System.Web.HttpResponseBase response, System.Web.HttpSessionStateBase session)
        {
            HttpCookie myCookie = new HttpCookie("rfs.username");

            myCookie = request.Cookies["rfs.username"];
            if (myCookie != null)
            {
                session[myCookie.Value] = "";
            }

            HttpCookie currentUserCookie = request.Cookies["rfs.username"];

            response.Cookies.Remove("rfs.username");
            if (currentUserCookie != null)
            {
                currentUserCookie.Expires = DateTime.Now.AddDays(-10);
                currentUserCookie.Value   = null;
                response.SetCookie(currentUserCookie);
            }
        }
예제 #40
0
        protected override void WriteFile(System.Web.HttpResponseBase response)
        {
            iCalendar iCal = new iCalendar();

            var evnt = iCal.Create <Event>();

            evnt.Summary            = _info.Name;
            evnt.Start              = new iCalDateTime(_info.StartDate);
            evnt.Duration           = _info.Duration;
            evnt.GeographicLocation = _info.Geo;
            evnt.Location           = _info.Location;
            evnt.Url = new Uri(_info.Url);

            //iCal.Events.Add(evnt);

            var    ser    = new iCalendarSerializer();
            string result = ser.SerializeToString(iCal);

            //iCalendarSerializer serializer = new iCalendarSerializer(iCal);
            //string result = serializer.SerializeToString();
            response.ContentEncoding = Encoding.UTF8;
            response.Write(result);
        }
예제 #41
0
 /// <summary>
 /// 输出JS文本到客户端
 public static void WriteJavaScript(this HttpResponseBase Response, JavaScript script)
 {
     Response.ContentType     = "text/html";
     Response.ContentEncoding = Encoding.UTF8;
     Response.Write(script.ToString());
 }
예제 #42
0
 /// <summary>
 /// Writes the file to the response.
 /// </summary>
 /// <param name="response">The response object.</param>
 protected override void WriteFile(System.Web.HttpResponseBase response)
 {
     this.Content(response.OutputStream);
 }
예제 #43
0
 public static Stream GetBody(this HttpResponse r)
 {
     return(r.Body);
 }
예제 #44
0
파일: T4MVC.cs 프로젝트: duncansmart/T4MVC
 protected override void WriteFile(System.Web.HttpResponseBase response)
 {
 }
        public void SignIn(int adminId, string userName, string firstName, string lastName, bool isSystemUser, System.Web.HttpResponseBase httpResponseBase)
        {
            AdminData adminData = new AdminData
            {
                AdminId      = adminId,
                UserName     = userName,
                LastName     = lastName,
                FirstName    = firstName,
                IsSystemUser = isSystemUser
            };

            string encodedTicket = FormsAuthentication.Encrypt(
                new FormsAuthenticationTicket(
                    version: 1,
                    name: userName,
                    issueDate: DateTime.UtcNow,
                    expiration: DateTime.UtcNow.Add(FormsAuthentication.Timeout),
                    isPersistent: true,
                    userData: adminData.ToString())
                );

            HttpCookie httpCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encodedTicket);

            httpResponseBase.Cookies.Add(httpCookie);
        }
예제 #46
0
 /// <summary>
 /// Writes the file to the response.
 /// </summary>
 /// <param name="response">The response object.</param>
 protected override void WriteFile(System.Web.HttpResponseBase response)
 {
     response.Buffer = bufferOutput;
     content(response.OutputStream);
 }
예제 #47
0
 /// <summary>
 /// Redirects the specified response.
 /// </summary>
 /// <param name="response">The response.</param>
 /// <param name="responseCode">The response code.</param>
 /// <param name="url">The URL.</param>
 public static void Redirect(this HttpResponseBase response, int responseCode, string url)
 {
     Redirect(HttpContext.Current.Response, responseCode, url);
 }
예제 #48
0
 private void Init(NetHttpRequest request, NetHttpResponse response)
 {
     _request      = request;
     _response     = response;
     _utcTimestamp = DateTime.UtcNow;
 }