locked
How to send object from HTTP Handler to aspx file RRS feed

  • Question

  • User674852329 posted

     Hi, friends

    First time I have used HTTP handler, so I have tough time to send object from HTTP handler to .aspx page

    Actually I am trying to upload a file, so in my default.aspx page if i click on upload button at that time http handler comes in picture and it saves file in system as well as in database. this handler code is written in  upload.cs file.

    Now I want to transfer file object from upload.cs to Default.aspx page, how I can transfer that object ?

    Thanks in advance 

    Wednesday, October 21, 2009 12:40 AM

Answers

  • User681263371 posted

    The simplest way would be to store the object in session and access the same in Default.aspx. The other way round would be to serialize the object and send the xml stream as the response to default.aspx page and try deserializing the object by reading the response stream. As far as I know other than this there is no way to pass objects.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 21, 2009 8:13 AM
  • User674852329 posted

    I used my http handler to save file,

    so when i hit on upload button at that time my handler will called and it call ProcessRequest() function.


    So it look like this


    public void ProcessRequest(HttpContext context)
        {
            

            if(context.Request.Files.Count > 0)
            {
                // get the applications path

    save file in database and as well as some location


    [ NOW HERE WHEN IT EXIT THEN IT WILL GO BACK MY default.aspx PAGE] 

    }


    In that page I need file name so I can do further work in that default.aspx page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 22, 2009 12:59 PM

All replies

  • User681263371 posted

    The simplest way would be to store the object in session and access the same in Default.aspx. The other way round would be to serialize the object and send the xml stream as the response to default.aspx page and try deserializing the object by reading the response stream. As far as I know other than this there is no way to pass objects.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 21, 2009 8:13 AM
  • User674852329 posted

    Thank you for your reply,

     

    Yes you are right, we can use Session variable, currently as a temporary I have used this, but you know session is not reliable variable.

     

    Two quick questions comes in my mind

     

    1) How to send and retrieve serialize object to default.aspx page

     

    2) How can I get that object in default.aspx page, means i send serialize object from my handler then how I can know that my handler return some value or object ?, Because I am unable to find any event in default.aspx page which tells me now handlers returns value.

     

    One is post back event from which i can figure out, but I am not feeling secure to write code in this event.

    Wednesday, October 21, 2009 10:17 AM
  • User681263371 posted

    To help you more it would be great if you could post some code of what you are doing in the HttpHandler. Based on your code I can give you some sample code.

    Wednesday, October 21, 2009 10:28 AM
  • User674852329 posted

    I used my http handler to save file,

    so when i hit on upload button at that time my handler will called and it call ProcessRequest() function.


    So it look like this


    public void ProcessRequest(HttpContext context)
        {
            

            if(context.Request.Files.Count > 0)
            {
                // get the applications path

    save file in database and as well as some location


    [ NOW HERE WHEN IT EXIT THEN IT WILL GO BACK MY default.aspx PAGE] 

    }


    In that page I need file name so I can do further work in that default.aspx page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 22, 2009 12:59 PM