本文整理汇总了C#中IHttpSession类的典型用法代码示例。如果您正苦于以下问题:C# IHttpSession类的具体用法?C# IHttpSession怎么用?C# IHttpSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHttpSession类属于命名空间,在下文中一共展示了IHttpSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Process
public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
{
if (request.UriPath == "/createjob")
{
var reader = new StreamReader(request.Body);
string posttext = reader.ReadToEnd();
var jobid = _worker.JobController.CreateJob(posttext);
Console.WriteLine("Worker: Created job #" + jobid + ": Posted text: " + posttext);
response.Encoding = Encoding.UTF8;
response.Body = new MemoryStream(response.Encoding.GetBytes(jobid));
return true;
}
var m1 = Regex.Match(request.UriPath, "/job/([0-9a-z-]+)/assemblies");
if (m1.Success)
{
var jobid = m1.Groups[1].Value;
var bytes = Utilities.ReadAllBytes(request.Body);
var filename = request.QueryString["name"].Value;
_worker.JobController.AddAssembly(jobid,filename,bytes);
response.Body = new MemoryStream(response.Encoding.GetBytes("OK"));
return true;
}
var m2 = Regex.Match(request.UriPath, "/job/([0-9a-z-]+)/start");
if (m2.Success)
{
var jobid = m2.Groups[1].Value;
var reader = new StreamReader(request.Body);
_worker.JobController.Start(jobid);
response.Body = new MemoryStream(response.Encoding.GetBytes("OK"));
return true;
}
Console.WriteLine("Unhandled worker request: " + request.UriPath);
/*
Console.WriteLine("Worker request: "+request.UriPath);
response.Encoding = Encoding.UTF8;
string body = "Hej från worker; localpath=" + request.UriPath + ", querystring=" + request.QueryString+", method="+request.Method;
response.Body = new MemoryStream(response.Encoding.GetBytes(body));
return true;*/
return false;
}
开发者ID:possan,项目名称:mapreduce,代码行数:45,代码来源:WorkerRequestHandler.cs
示例17: Authenticate
/// <summary>
/// Checks authentication with ZMA
/// </summary>
/// <param name="request"></param>
/// <param name="session"></param>
private void Authenticate(IHttpRequest request, IHttpSession session)
{
if (request.Param["login"].Value != null)
{
if (!webLogin.ContainsKey(session.Id))
webLogin.Add(session.Id, false);
String username = request.Param["username"].Value;
String password = request.Param["password"].Value;
var userlist = UserCollectionSingletone.GetInstance();
var user = userlist.GetUserByLogin(username);
// First check if we have access and the if we can login :-)
// I use SHA256 with salt so avoid using other authentications
if (!user.Generated && user.HasWebAccess && HashProvider.GetHash(password, HashProvider.SHA256) == user.PasswordHash)
{
webLogin[session.Id] = true;
}
}
}
开发者ID:BGCX261,项目名称:zma-svn-to-git,代码行数:24,代码来源:MyModule.cs
示例18: Process
public override bool Process(IHttpRequest request, IHttpResponse response, IHttpSession session)
{
_log.Write(this, LogPrio.Trace, String.Format("Begin handling Rack request for {0}", request.Uri));
var rackRequest = request.ToRackRequest();
var rackResponse = new RackResponse(response.Body);
//this will write to the body. We may want to set headers first, so may need some thought.
_rack.HandleRequest(rackRequest, rackResponse);
response.Status = (HttpStatusCode)rackResponse.Status;
foreach (var header in rackResponse.Headers)
if (header.Key.ToLower() != "content-length")
response.AddHeader(header.Key, header.Value);
_log.Write(this, LogPrio.Trace, String.Format("Finished handling Rack request for {0}", request.Uri));
return true;
}
开发者ID:PlasticLizard,项目名称:Bracket,代码行数:19,代码来源:RackRequestHandler.cs
示例19: 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 (!Enum.TryParse(request.Param["mediatype"].Value, out mediaType))
return false;
if (!Enum.TryParse(request.Param["fanarttype"].Value, out fanArtType))
return false;
string name = request.Param["name"].Value;
if (string.IsNullOrWhiteSpace(name))
return false;
name = name.Decode(); // For safe handling of "&" character in name
// Both values are optional
int.TryParse(request.Param["width"].Value, out maxWidth);
int.TryParse(request.Param["height"].Value, out maxHeight);
IList<FanArtImage> files = fanart.GetFanArt(mediaType, fanArtType, name, maxWidth, maxHeight, true);
if (files == null || files.Count == 0)
{
#if DEBUG
ServiceRegistration.Get<ILogger>().Debug("No FanArt for {0} '{1}' of type '{2}'", name, fanArtType, mediaType);
#endif
return false;
}
using (MemoryStream memoryStream = new MemoryStream(files[0].BinaryData))
SendWholeStream(response, memoryStream, false);
return true;
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:48,代码来源:FanartAccessModule.cs
示例20: 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)
{
Authenticate(request, session);
if (IsAuthenticated(session))
{
SendCommand(request, session);
StreamWriter writer = new StreamWriter(response.Body);
writer.Write(LoadFile("management.html"));
writer.Flush();
}
else
{
StreamWriter writer = new StreamWriter(response.Body);
writer.Write(LoadFile("index.html"));
writer.Flush();
}
// return true to tell webserver that we've handled the url
return true;
}
开发者ID:BGCX261,项目名称:zma-svn-to-git,代码行数:28,代码来源:MyModule.cs
注:本文中的IHttpSession类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论