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


C# IHttpSession类代码示例

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


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

示例1: Process

 public void Process(RouteValues routeValues, IHttpRequest request, IHttpResponse response, IHttpSession session)
 {
     string output = _action.Invoke(new ActionParameters(routeValues, request, response, session));
     var writer = new StreamWriter(response.Body);
     writer.Write(output);
     writer.Flush();
 }
开发者ID:gudmundurh,项目名称:Frank,代码行数:7,代码来源:FrankRouteHandler.cs

示例2: Process

		public bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
		{

			bool handled = false;

			if (!handled)
			{
				handled = rpcModule.Process(request, response, session);
			}

			if (!handled)
			{
				handled = frontendModule.Process(request, response, session);
			}

			if (!handled)
			{

				StreamWriter writer = new StreamWriter(response.Body);
				writer.Write("<html>\n<head>\n");
				writer.Write("<title>" + "Page not found" + "</title>\n");
				writer.Write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n");
				writer.Write("</head>\n");
				writer.Write("<body>\n<h2>Page not found</h2>\n");

				writer.Write("\n</body>\n</html>\n");
				writer.Flush();

				handled = true;
			}
			return handled;
		}
开发者ID:Lyror,项目名称:EmployeeManagement,代码行数:32,代码来源:DispatcherModule.cs

示例3: Process

 public override Boolean Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
 {
     if (request.UriPath.StartsWith("/!") || request.UriPath.StartsWith("/$"))
     {
         StreamWriter writer = new StreamWriter(response.Body, Encoding.UTF8);
         String ret;
         try
         {
             Object obj = this.Servant.Host.RequestManager.Execute(Request.Parse(request.UriPath.UriDecode()));
             ret = obj != null ? obj.ToString() : "(No return data)";
             response.ContentType = ret.StartsWith("<")
                 ? "application/xml"
                 : ret.StartsWith("{") || ret.StartsWith("[")
                       ? "application/json"
                       : "text/plain";
             writer.Write(ret);
         }
         catch (Exception ex)
         {
             response.Status = HttpStatusCode.InternalServerError;
             response.ContentType = "text/plain";
             writer.WriteLine("ERROR: " + ex);
         }
         finally
         {
             writer.Flush();
         }
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:urasandesu,项目名称:metatweet,代码行数:34,代码来源:RequestHandler.cs

示例4: UserProvider

 public UserProvider(IRepository<Account> accountRepository, IRepository<Player> playerRepository, 
     IHttpSession httpSession)
 {
     _accountRepository = accountRepository;
     _playerRepository = playerRepository;
     _httpSession = httpSession;
 }
开发者ID:brocksamson,项目名称:Evil,代码行数:7,代码来源:UserProvider.cs

示例5: Process

        public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
        {
            if (_ignoredPaths.Contains(request.Uri.AbsolutePath))
                return true;

            TextWriter writer = new StreamWriter(response.Body);

            try
            {
                string fileContents = File.ReadAllText("resources" + request.Uri.AbsolutePath);
                writer.Write(fileContents);
            }
            catch (Exception ex)
            {
                response.ContentType = "text/plain; charset=UTF-8";
                writer.WriteLine(ex.Message);
                writer.WriteLine(ex.StackTrace);
            }
            finally
            {
                writer.Flush();
            }

            return true;
        }
开发者ID:caelum,项目名称:NET-Selenium-DSL,代码行数:25,代码来源:FileReaderModule.cs

示例6: Process

    /// <summary>
    /// Method that process the url
    /// </summary>
    /// <param name="request">Information sent by the browser about the request</param>
    /// <param name="response">Information that is being sent back to the client.</param>
    /// <param name="session">Session used to </param>
    /// <returns>true if this module handled the request.</returns>
    public override bool Process (IHttpRequest request, IHttpResponse response, IHttpSession session)
    {
      Uri uri = request.Uri;
      if (!uri.AbsolutePath.StartsWith("/FanartService"))
        return false;

      IFanArtService fanart = ServiceRegistration.Get<IFanArtService>(false);
      if (fanart == null)
        return false;

      FanArtConstants.FanArtMediaType mediaType;
      FanArtConstants.FanArtType fanArtType;
      int maxWidth;
      int maxHeight;
      if (uri.Segments.Length < 4)
        return false;
      if (!Enum.TryParse(GetSegmentWithoutSlash(uri,2), out mediaType))
        return false;
      if (!Enum.TryParse(GetSegmentWithoutSlash(uri, 3), out fanArtType))
        return false;
      string name = GetSegmentWithoutSlash(uri, 4);

      // Both values are optional
      int.TryParse(GetSegmentWithoutSlash(uri, 5), out maxWidth);
      int.TryParse(GetSegmentWithoutSlash(uri, 6), out maxHeight);

      IList<FanArtImage> files = fanart.GetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, true);
      if (files == null || files.Count == 0)
        return false;

      using (MemoryStream memoryStream = new MemoryStream(files[0].BinaryData))
        SendWholeStream(response, memoryStream, false);
      return true;
    }
开发者ID:HeinA,项目名称:MediaPortal-2,代码行数:41,代码来源:FanartAccessModule.cs

示例7: ActionParameters

 public ActionParameters(RouteValues routeValues, IHttpRequest request, IHttpResponse response,
                         IHttpSession session)
 {
     RouteValues = routeValues;
     Request = request;
     Response = response;
     Session = session;
     Store = _theStore;
 }
开发者ID:gudmundurh,项目名称:Frank,代码行数:9,代码来源:ActionParameters.cs

示例8: Process

            public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
            {
                Console.WriteLine(request.QueryString["id"].Value + " got request");
                response.Status = HttpStatusCode.OK;

                byte[] buffer = Encoding.ASCII.GetBytes(request.QueryString["id"].Value);
                response.Body.Write(buffer, 0, buffer.Length);

                return true;
            }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:10,代码来源:HttpServerLoadTests.cs

示例9: WebServerConnection

        public WebServerConnection(IHttpSession session, IPAddress ipAddress)
        {
            if (session == null)
                throw new ArgumentNullException ("session");
            if (ipAddress == null)
                throw new ArgumentNullException ("ipAddress");

            IPAddress = ipAddress;
            this.IsConnected = true;
            this.session = session;
        }
开发者ID:ermau,项目名称:Gablarski,代码行数:11,代码来源:WebServerConnection.cs

示例10: OrderController

 public OrderController(IGetProductService getProductService,
     IHttpSession session, IOrderProcessor orderProcessor,
     IGetObjectService<Order> getOrderService,
     ISaveObjectService<Order> saveOrderService)
 {
     _session = session;
     _orderProcessor = orderProcessor;
     _getOrderService = getOrderService;
     _saveOrderService = saveOrderService;
     _getProductService = getProductService;
 }
开发者ID:JonKruger,项目名称:MvcStarterProject,代码行数:11,代码来源:OrderController.cs

示例11: ProcessSection

        protected override bool ProcessSection(IHttpRequest request, IHttpResponse response, IHttpSession session)
        {
            if (request.UriParts.Length == 1)
            {
                PermissionDeniedMessage pmsg;
                var listmsg = Connections.SendAndReceive<UserListMessage> (new RequestUserListMessage(UserListMode.All), session, out pmsg);

                if (pmsg != null)
                {
                    WriteAndFlush (response, "{ \"error\": \"Permission denied\" }");
                    return true;
                }

                WriteAndFlush (response, JsonConvert.SerializeObject (listmsg.Users.RunQuery (request.QueryString)));
                return true;
            }
            else if (request.UriParts.Length == 2)
            {
                int userId;
                if (!request.TryGetItemId (out userId))
                {
                    WriteAndFlush (response, "{ \"error\": \"Invalid request\" }");
                    return true;
                }

                switch (request.UriParts[1].Trim().ToLower())
                {
                    //case "delete":
                    case "edit":
                    {
                        IHttpInput input = (request.Method.ToLower() == "post") ? request.Form : request.QueryString;

                        if (!input.ContainsAndNotNull ("SessionId", "Permissions") || session.Id != input["SessionId"].Value)
                        {
                            WriteAndFlush (response, "{ \"error\": \"Invalid request\" }");
                            return true;
                        }

                        var permissions = JsonConvert.DeserializeObject<IEnumerable<Permission>> (input["Permissions"].Value).ToList();
                        if (permissions.Count == 0)
                            return true;

                        Connections.Send (new SetPermissionsMessage (userId, permissions), session);
                        return true;
                    }
                }
            }

            WriteAndFlush (response, "{ \"error\": \"Invalid request\" }");
            return true;
        }
开发者ID:ermau,项目名称:Gablarski,代码行数:51,代码来源:UserModule.cs

示例12: Process

        /// <summary>
        /// Method that process the URL
        /// </summary>
        /// <param name="request">Information sent by the browser about the request</param>
        /// <param name="response">Information that is being sent back to the client.</param>
        /// <param name="session">Session used to </param>
        /// <returns>true if this module handled the request.</returns>
        public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
        {
            if (session["times"] == null)
                session["times"] = 1;
            else
                session["times"] = ((int) session["times"]) + 1;

            StreamWriter writer = new StreamWriter(response.Body);
            writer.WriteLine("Hello dude, you have been here " + session["times"] + " times.");
            writer.Flush();

            // return true to tell webserver that we've handled the url
            return true;
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:21,代码来源:MyModule.cs

示例13: ProcessSection

        protected override bool ProcessSection(IHttpRequest request, IHttpResponse response, IHttpSession session)
        {
            if (request.UriParts.Length == 1)
            {
                PermissionDeniedMessage denied;
                var msg = Connections.SendAndReceive<ChannelListMessage> (
                    new RequestChannelListMessage(), session, out denied);

                if (denied != null)
                {
                    WriteAndFlush (response, "{ \"error\": \"Permission denied\" }");
                    return true;
                }

                WriteAndFlush (response, JsonConvert.SerializeObject (new { DefaultChannel = msg.DefaultChannelId, Channels = msg.Channels.RunQuery (request.QueryString) }));
            }
            else if (request.UriParts.Length == 2)
            {
                /*if (request.Method.ToLower() != "post")
                    return false;*/

                IHttpInput input = (request.Method.ToLower() == "post") ? request.Form : request.QueryString;

                int channelId;
                switch (request.UriParts[1])
                {
                    case "delete":
                    case "edit":
                    {
                        if (!request.TryGetItemId (out channelId))
                        {
                            WriteAndFlush (response, "{ \"error\": \"Invalid channel ID\" }");
                            return true;
                        }

                        return SaveOrUpdateChannel (session, response, input, channelId, (request.UriParts[1] == "delete"));
                    }

                    case "new":
                        return SaveOrUpdateChannel (session, response, input, 0, false);
                }
            }
            else
            {
                return false;
            }

            return true;
        }
开发者ID:ermau,项目名称:Gablarski,代码行数:49,代码来源:ChannelModule.cs

示例14: Process

        public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
        {
            foreach (Route route in _routes)
            {
                if (request.Method != route.Method.ToString()) continue;

                RouteValues routeValues = route.Matches(request);

                if (routeValues == null) continue;

                route.RouteHandler.Process(routeValues, request, response, session);
                return true;
            }
            return false;
        }
开发者ID:gudmundurh,项目名称:Frank,代码行数:15,代码来源:FrankApp.cs

示例15: Process

        /// <summary>
        /// Method that process the url
        /// </summary>
        /// <param name="request">Information sent by the browser about the request</param>
        /// <param name="response">Information that is being sent back to the client.</param>
        /// <param name="session">Session used to </param>
        public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
        {
            if (!CanHandle(request.Uri))
                return false;

            bool handled = false;
            foreach (HttpModule module in _modules)
            {
                if (module.Process(request, response, session))
                    handled = true;
            }

            if (!handled)
                response.Status = HttpStatusCode.NotFound;

            return true;
        }
开发者ID:BGCX261,项目名称:zma-svn-to-git,代码行数:23,代码来源:WebSiteModule.cs


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