473,382 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to get the session-object within an IHttpHandler

I've read all the items about the IHttpHandler and the session-object
and I see nothing wrong with my code, but still I have no session
object.

This is my code:
Imports System
Imports System.Data
Imports System.Web
imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.IO

Public Class Upload
Implements IHttpHandler
Implements IRequiresSessionState

'Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler
'Implements IRequiresSessionState

'Public Sub ProcessRequest(ByVal context As HttpContext) Implements
System.Web.IHttpHandler.ProcessRequest',
system.web.sessionstate.IRequiresSessionState
Public Overridable Sub ProcessRequest(ByVal context As HttpContext)
Implements IHttpHandler.ProcessRequest
Dim objSession As HttpSessionState = context.current.Session
If context.Request.Files.Count 0 Then
Dim tempFile As String = context.Request.PhysicalApplicationPath
Dim j As Integer = 0
While j < context.Request.Files.Count
Dim uploadFile As HttpPostedFile = context.Request.Files(j)
If uploadFile.ContentLength 0 Then
try
Dim outputdir As string = objSession("dir") & ""

Dim sUploadDir as string = "\\fileserver\test2\"
if outputdir.length 0 Then
uploadFile.SaveAs(outputdir & uploadFile.FileName)
Else
uploadFile.SaveAs(sUploadDir & uploadFile.FileName)
End If
catch ex as exception
Dim sOut as string = "uploaderror.log"

If File.Exists(sOut) Then File.Delete (sOut)
Dim sw As StreamWriter = New StreamWriter(sOut)
sw.WriteLine (ex.tostring)
sw.Close()
end try
End If
j += 1
End While
End If
HttpContext.Current.Response.Write(" ")
End Sub

Public Overridable ReadOnly Property IsReusable() As Boolean
Implements IHttpHandler.IsReusable
Get
Return True
End Get
End Property
End Class

My web.config looks like:
<httpHandlers>
<remove verb="POST,GET" path="Upload.axd"/>
<add verb="POST,GET" path="Upload.axd" type="Upload"/>

</httpHandlers>
<httpRuntime maxRequestLength="1550000"/>
<sessionState mode="StateServer"
stateConnectionString="tcpip=127.0.0.1:42424"
cookieless="false"
timeout="200"/>

The start aspx looks like:
<%@ Page Language="VB" AutoEventWireup="true" enableviewstate="true"
AspCompat="false" Trace="false" Debug="true"%>

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.Common" %>
<script language="VB" runat="server">

Sub Page_Load(sender as Object, e as EventArgs)
Session("dir")= "\\server\test1\"
End Sub

No error appears, but all the uploaded files are uploaded in the
test2-directory, but I want them in the directory what is set in the
session-object.

I've started with IIS 5, but now I'm testing with IIS 6. But it's not
making any difference.

I'm hoping that someone can tell me what I've forgotten or what I'm
doing wrong.

Is there anybody out there, who can help me???

Dec 20 '06 #1
1 4288
The reason why I don't have my session is because of the redirecting
object is not my aspx-page but a flash object.

Dec 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Damien | last post by:
Hi to all, I'm currently re-designing our intranet : nice and lean CSS2, cleaned-up PHP 4.3.7, better-normalized MySQL ;o). So I've started using the $_SESSION variable instead of register_globals...
1
by: mudge | last post by:
I'm running PHP Version 4.3.10. I'm trying to make it so that when a person logs in using a user name and password that their session is valid and continues for a few months so they don't have to...
6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
0
by: joseph conrad | last post by:
Hi, I tried to implement my own session handler in order to keep control on the process the drawback I foun it is not creating and storing in my cookie the PHPSESSID variable anymore. reading te...
7
by: aroraamit81 | last post by:
Well Guys, Here is a very strange trouble. When more than one users request tto same page at the same time then our session gets conflicted. Moreover I printed my SessionID, strangely but true I...
0
by: TRB_NV | last post by:
I'd been using an Access database based shopping cart, but wanted to change it so that it would use session variables. I have a form that's submitted to a page called addtocart.asp that contains...
2
by: Gordon Burditt | last post by:
I had this idea about preventing session fixation, and I'm wondering what anyone else thinks about it. The idea is, essentially, don't allow session ids that YOUR PHP didn't generate (and aren't...
5
by: lyealain | last post by:
<% If Session("username") = "" Then Response.Redirect("/CLS/Login.asp") End If Dim conn Dim connectstr Dim db_name, db_username, db_userpassword Dim db_server Dim res
3
by: mikeboston | last post by:
Hi, I am attempting to use php session variables on a server which is running Red Hat Linux, but the variables don't seem to be getting passed between pages. I have tried the same exact test...
1
by: KidQuin | last post by:
I am having problems with session value between pages. Happening in both firefox and IE7. I go between page by links so I know it's not header changes. I use session_start as the first line on the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.