Reading ASP.NET Response Header

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: Reading ASP.NET Response Header

    "_jpg_" <developersdexgroups.10.jgilbert@xoxy.net> wrote in message
    news:uyioh0UXDHA.3232@tk2msftngp13.phx.gbl...
    > Ideally I would like all the headers, or be able to set whatever I need
    > to so that I can modify a response object to recreate whatever the
    > previous one would have.
    I believe the technical term for this is "SOL". :-(

    I have written an HttpModule which can capture the complete request and
    response - except for the response headers! When I got to that point in the
    code, I found that they literally do not exist as a collection, and do not
    exist in any fashion until after the request is completely over. Instead,
    ASP.NET produces its headers by calling methods on a class provided by the
    hosting environment.

    Now, there's your one hope. If your code has to work in the completely
    general case, give up now and save yourself the trouble. But if you can run
    your code under your own host (i.e., your own web server), then you can
    produce a hack to make this happen. I managed to do this by hacking a
    version of Microsoft's Cassini web server (a part of the Web Matrix project
    at [url]http://asp.net/webmatrix/default.aspx?tabIndex=4&tabId=46[/url]). As it turns
    out, this was a fairly nasty hack, involving the server setting something in
    one of the server variables for the HttpModule to read to pass back to a
    static method in the server - it was pretty gross.

    Under no circumstances would I consider such a hack suitable for any
    production purpose. For any such purpose, I'd say, "sorry, find another way
    to do it". For instance, you might be better off writing a network sniffer
    or a custom proxy server than to screw around with private fields which are
    as likely as not to change in the next .n release, or even on a service pack
    release. "private" really means, "none of your business".

    Good Luck. You'll need it.
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]


    John Saunders Guest

  2. Similar Questions and Discussions

    1. Proxy class not reading data returned in SOAP response
      I'm trying to create a .NET client to consume a Java web service. The company that owns the web service does not publish a WSDL, but they do...
    2. #39984 [NEW]: Response header sent as 302 despite being set to 301
      From: marc dot bau at gmx dot net Operating system: WinXP PHP version: 5.2.0 PHP Bug Type: IIS related Bug description: ...
    3. AW7 vs. DirectorMX for psychology experiment using response times AND response answers
      Hello, I'm very new to application design, but need to develop a web based application to use at multiple schools as part of an experimental...
    4. Response.Add Header problems (Content-disposition)
      All, I have an ASP Application in which users can save a recordset as an Excel spreadsheet should they choose to do so. When the app was on ...
    5. reading header? results from another script
      Here's the scenario: I want to call the script 'file1.cgi', passing the desired parameters, store the parameters in mysql, (it works up to here)...
  3. #2

    Default Re: Reading ASP.NET Response Header

    Ok thanks for your help - my solution cannot require a modified web
    server, which seems to me like more of a hack than mine!

    I believe that the best solution for me will be to clone the whole
    HttpResponse object (using reflection), and then clone it back over the
    top of the new one. This should at least mean small changes such as
    field renaming won't break it (yes I know calls to external
    methods/deeper objects still could). I could support only specific
    versions of the framework - and this method will be fine for all the
    existing versions.

    If Microsoft manage to break this down the line there are quite a few
    other classes that I could use looking at the OutputCacheModule - none
    of which are actually public again :-( It's really starting to annoy me
    how closed the .NET api is compared to J2SE. Most of the classes seem to
    be internal, as well as the amount they have sealed...

    thanks

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    _jpg_ Guest

  4. #3

    Default Re: Reading ASP.NET Response Header

    "_jpg_" <developersdexgroups.10.jgilbert@xoxy.net> wrote in message
    news:%23KlfhYdXDHA.2236@TK2MSFTNGP10.phx.gbl...
    > Ok thanks for your help - my solution cannot require a modified web
    > server, which seems to me like more of a hack than mine!
    >
    > I believe that the best solution for me will be to clone the whole
    > HttpResponse object (using reflection), and then clone it back over the
    > top of the new one. This should at least mean small changes such as
    > field renaming won't break it (yes I know calls to external
    > methods/deeper objects still could). I could support only specific
    > versions of the framework - and this method will be fine for all the
    > existing versions.
    My immediate reaction is "you must be crazy". After calming down and
    thinking about it for a while, I've decided to stick with my immediate
    reaction.

    It sounds like the problem you were asked to solve was, "get me all the
    response headers for all the requests sent to this web site". It seems to me
    that the solution is to "get the response headers from where they're meant
    to be seen - in the HTTP header of the response". It would take a change in
    the HTTP protocol to break _that_ code, whereas it would take only a sneeze
    to break yours.
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]


    John Saunders Guest

  5. #4

    Default Re: Reading ASP.NET Response Header

    Ok, I have a problem with .NET postbacks. I cannot return any data from
    posts, all requests will be going through a kind of proxy, which cannot
    return a post response back to the client (don't ask me why, there are
    reasons and it's not under my control to change). Therefore I would like
    detect all postbacks, cache the response, issue a redirect instead of
    the response (back to my page), then serve this cached response.

    I know it's convoluted but all data must come from a GET to the proxy.

    Thanks

    jpg

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    _jpg_ Guest

  6. #5

    Default Re: Reading ASP.NET Response Header

    I agree this would be the best place to retrieve them, however I must
    store them & issue a redirect, and if they have already been sent then I
    am too late. I can only achieve this if all requests go through some
    kind of proxy, which is very likely to not make it transparent to the
    asp.net pages.

    I imagine I could do it if I implemented the whole thing in a ISAPI
    filter, which I may look at, but it seems stupid to me that I can't do
    it in the framework itself.

    Why do you see the reflection approach as such a problem if it is always
    bound to a specific version of System.Web.dll? Updating my code for the
    next release would not be a problem.

    jpp

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    _jpg_ Guest

  7. #6

    Default Re: Reading ASP.NET Response Header

    I could use a proxy, but that means another install on the web server,
    or another machine. I cannot force users to do this. It also would mean
    that developers would always have to hit this proxy instead of their asp
    page, which is hardly transparent to them.

    You say that reflection is not maintainable because the implementation
    may change tomorrow, but why can't I just specify the version I can work
    with? I'm sure I can fairly easily write a slightly different
    implementation should the framework change. I completely agree with what
    you're saying about private fields - I would never normally do this, it
    is only due to hitting Microsofts closed API.

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    _jpg_ Guest

  8. #7

    Default Re: Reading ASP.NET Response Header

    "_jpg_" <developersdexgroups.10.jgilbert@xoxy.net> wrote in message
    news:O$y79geXDHA.1816@TK2MSFTNGP09.phx.gbl...
    > I could use a proxy, but that means another install on the web server,
    > or another machine. I cannot force users to do this. It also would mean
    > that developers would always have to hit this proxy instead of their asp
    > page, which is hardly transparent to them.
    >
    > You say that reflection is not maintainable because the implementation
    > may change tomorrow, but why can't I just specify the version I can work
    > with? I'm sure I can fairly easily write a slightly different
    > implementation should the framework change. I completely agree with what
    > you're saying about private fields - I would never normally do this, it
    > is only due to hitting Microsofts closed API.
    The API may be closed for a reason, had you considered that?

    It wouldn't surprise me to find they can change "private" data in service
    packs or QFE patches. Are you saying that you can't require your users to
    install a piece of software, but you're ok with preventing them from
    installing necessary patches?

    How do you feel about people who write code that depends on the exact text
    of an exception message? Let the spelling get corrected and they're screwed!
    You want to write code which could preclude Microsoft from making the code
    equivalent of a typo!
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]


    John Saunders Guest

  9. #8

    Default Re: Reading ASP.NET Response Header

    jpg,

    "For education purpose only."
    It looks like you are under security constraints?
    Very Interesting problem you have.
    I Don't fully understand it yet. Sorry.

    Client hits a button on her/his browser then what?
    she/he can not get a direct response from your server? becasue of proxy?
    then you cach the response but you redirect first
    then you server the cached response from prevous request?
    did I understand this correctly or get close?
    I know you might not have time to explain this to me, but if you can please
    do so
    Thank you sooooo much

    J

    "_jpg_" <developersdexgroups.10.jgilbert@xoxy.net> wrote in message
    news:ulC6ELeXDHA.652@TK2MSFTNGP10.phx.gbl...
    > Ok, I have a problem with .NET postbacks. I cannot return any data from
    > posts, all requests will be going through a kind of proxy, which cannot
    > return a post response back to the client (don't ask me why, there are
    > reasons and it's not under my control to change). Therefore I would like
    > detect all postbacks, cache the response, issue a redirect instead of
    > the response (back to my page), then serve this cached response.
    >
    > I know it's convoluted but all data must come from a GET to the proxy.
    >
    > Thanks
    >
    > jpg
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    MS News \(MS ILM\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139