|
| Writing A Cookie Using an HTTP Handler and HTTPWebRequest |
 |
Fri, 29 Feb 2008 02:47:11 +000 |
I have web form A that is calling HTTP Handler B.
Both A and B are in the same domain.
A calls B using an HTTPWebRequest
B tries to write a cookie by creating an HTTP cookie and then writing the cookie
out by calling: context.Response.Cookies.Set(myCookieName)
B does a Response.Write("Success");
Response goes back to A. A can see "Success", however NO cookie was
dropped by B.
Does anyone know why a cookie wasn't dropped? It seems whenever I call a page or
handler using HTTPWebRequest, and then that page tries to drop a cookie... the
cookie never gets dropped even though both pages are in the same domain.
Any ideas as to why?
Thanks!
|
| Post Reply
|
| Re: Writing A Cookie Using an HTTP Handler and HTTPWebRequest |
 |
Fri, 29 Feb 2008 05:41:20 +000 |
Not sure why it would not work. Would something like this work for ya if not
what does your code look like....
Module
Imports System.Web
Public Class RequestModule
Implements IHttpModule
Public Sub Init(ByVal app As HttpApplication) Implements IHttpModule.Init
AddHandler app.BeginRequest, AddressOf MyBeginRequest
AddHandler app.EndRequest, AddressOf MyEndRequest
End Sub
Public Sub Dispose() Implements IHttpModule.Dispose
'clean code if anyEnd Sub
Public Sub MyBeginRequest(ByVal s As Object, ByVal e As EventArgs)
Dim app As HttpApplication
app = CType(s, HttpApplication)
app.Response.Write("<h4>Request Begins
Here...</h4>")
Dim newCookie As HttpCookie = New HttpCookie("newCookie")
newCookie.Values.Add("Success", "Success")
HttpContext.Current.Response.Cookies.Add(newCookie)
End Sub
Public Sub MyEndRequest(ByVal s As Object, ByVal e As EventArgs)
Dim app As HttpApplication
app = CType(s, HttpApplication)
app.Response.Write("<h4>Request Ends
Here...</h4>")
End Sub
End Class
Web Config...
<system.web>
<httpModules>
<add type="RequestModule" name="RequestModule"
/>
</httpModules>
|
| Post Reply
|
|
|
|
|
|
|
|
|
|