473,382 Members | 1,336 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.

ProcessRequest ASHX called Twice Causes Session variable Loss

hi

any help,advice,tips etc are greatly appreciated.

i've got an ashx page being called to handle the displaying of an Word doc. -

.NET 2.0, c#, running local on XP Pro

ProcessRequest------------

public void ProcessRequest(HttpContext context)
{
/*
try
{
*/
int userpk = Convert.ToInt32(context.Session["userpk"]);
string cvfilename = context.Request["cvfilename"];

byte[] cv = DAC.GetCVBlob(userpk);

//context.Response.ContentType = "vnd.ms-word";
context.Response.ContentType = "application/octet-stream";
// context.Response.AddHeader("Content-Disposition", cvfilename);
context.Response.ClearContent();
//context.Response.AddHeader("Content-Disposition", cvfilename);
context.Response.AddHeader("Content-Disposition", "inline;filename=" + cvfilename);
context.Response.BinaryWrite(cv);
context.Response.End();
/*
}
catch(Exception e)
{
context.Response.Write(e);
}
*/
}

Now when this runs all is well and i get a prompt asking me if I want to Open, Save, Cancel this doc.

I click Open and the ProcessRequest page is called again, only this time the Session is null like its been abondaned and the page bombs out.

Kind regards

Dean
May 7 '07 #1
2 4282
I know how to solve this by using a querystring instead of a session variable but i'd then have to encrypt or generate a random userpk at user creation stage for security purposes, 2 things I'd like to avoid. Has anybody got any suggestion please as to how i can continue to use the session variables in this handler?

Thanks

Dean
May 9 '07 #2
kenobewan
4,871 Expert 4TB
I believe that it is worth creating a secure application. Here is an article that may help:
Chapter 10 – Building Secure ASP.NET Pages and Controls
May 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: db_guy | last post by:
Hi, we have a php-based application that is hosted by Yahoo! Webhosting. Ever since the application was created, it has been plagued by periodic session data loss. Here's a typical example: We...
0
by: Ross Dempster | last post by:
Hi everyone, this is quite involved but if anyone can help (or just likes a challenge!) i would very much appreciate it. Quick intro : I have forms based authentication (though i do it manually...
6
by: Martin | last post by:
Hi, Since I went ASP.NET with my global.asa (making it a global.asax) the application events are called just fine as well as the Session_OnStart event but the Session_OnEnd event is not. What is...
4
by: Chance Hopkins | last post by:
I've got the IRequiresSessionState interface implemented, but because of forms authentication my page fires twice and causes certain session functions to update twice which messes up my values. ...
0
by: pat.allan | last post by:
Hi All This seems to be a common problem here, but I've not found a solution yet to fix it for me. When I request a page through a browser, the page_load fires once. When I request the page's...
0
by: rh | last post by:
I'm trying to use an ASHX files to send WAV files back to the client. I have links to the ASHX page in an ASPX file and there is a FileID on the querystring. Everything works except the...
2
by: Diffident | last post by:
Hello All, I am trying to use a session variable in a custom handler's processrequest method. I am getting a null reference whenever I access the session variable. At this point of execution is...
7
by: tshad | last post by:
I thought I understood how the SaveViewState is working and was trying to use this (as per some code I found) to detect refreshes. It seemed to be working but I found that the SaveViewState was...
7
by: gnewsgroup | last post by:
In my asp.net 2.0 web application, in Web.config, I have timeout="30", s l i d i n g E x p i r a t i o n = "true" for the Authentication element. I suppose, this means that as long as we...
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: 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: 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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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.