Ask a Question related to ASP.NET General, Design and Development.
-
John Saunders #1
Re: Reading ASP.NET Response Header
"_jpg_" <developersdexgroups.10.jgilbert@xoxy.net> wrote in message
news:uyioh0UXDHA.3232@tk2msftngp13.phx.gbl...I believe the technical term for this is "SOL". :-(> 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 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
-
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... -
#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: ... -
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... -
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 ... -
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)... -
_jpg_ #2
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
-
John Saunders #3
Re: Reading ASP.NET Response Header
"_jpg_" <developersdexgroups.10.jgilbert@xoxy.net> wrote in message
news:%23KlfhYdXDHA.2236@TK2MSFTNGP10.phx.gbl...My immediate reaction is "you must be crazy". After calming down and> 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.
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
-
_jpg_ #4
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
-
_jpg_ #5
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
-
_jpg_ #6
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
-
John Saunders #7
Re: Reading ASP.NET Response Header
"_jpg_" <developersdexgroups.10.jgilbert@xoxy.net> wrote in message
news:O$y79geXDHA.1816@TK2MSFTNGP09.phx.gbl...The API may be closed for a reason, had you considered that?> 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.
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
-
MS News \(MS ILM\) #8
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



Reply With Quote

