S
ScottB
I’m working on an ASP.Net application that uses forms authentication and I
could use some help. I need to build some custom HTTPHandlers to handle
security on some word documents that I have on my website. I’ve created a
class named DocHandler (see the code below, thanks Atal Bihari Upadhyay)
which implements the IHTTPHandler interface. My problem is this: In the
ProcessRequest subprocedure, I want to create a condition that is based on
the User.Identity.IsAuthenticated property for the application but I’m not
sure how to expose or reference it. Ideally, the condition should say that
if the user is authenticated, then the user will have access to the word
document (*.doc). If the user tries to access the file without
authentication, they will get a message that says “Access denied, please
login properly!â€.
Imports System.Web
Imports System.Web.Security.FormsAuthentication
Namespace SpecialHTTPHandler
Public Class DocHandler
Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
If User.Identity.IsAuthenticated Then
context.Response.Buffer = True
context.Response.Clear()
context.Response.AddHeader("content-disposition", "attachement;
filename=x.doc")
context.Response.ContentType = "application/doc"
context.Response.WriteFile("pp.doc")
Else
context.Response.Write("Access denied, please login properly!")
End If
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return True
End Get
End Property
End Class
End Namespace
This problem has exceeded my level of experience so any help will be greatly
appreciated. Thanks in advance for your help.
could use some help. I need to build some custom HTTPHandlers to handle
security on some word documents that I have on my website. I’ve created a
class named DocHandler (see the code below, thanks Atal Bihari Upadhyay)
which implements the IHTTPHandler interface. My problem is this: In the
ProcessRequest subprocedure, I want to create a condition that is based on
the User.Identity.IsAuthenticated property for the application but I’m not
sure how to expose or reference it. Ideally, the condition should say that
if the user is authenticated, then the user will have access to the word
document (*.doc). If the user tries to access the file without
authentication, they will get a message that says “Access denied, please
login properly!â€.
Imports System.Web
Imports System.Web.Security.FormsAuthentication
Namespace SpecialHTTPHandler
Public Class DocHandler
Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
If User.Identity.IsAuthenticated Then
context.Response.Buffer = True
context.Response.Clear()
context.Response.AddHeader("content-disposition", "attachement;
filename=x.doc")
context.Response.ContentType = "application/doc"
context.Response.WriteFile("pp.doc")
Else
context.Response.Write("Access denied, please login properly!")
End If
End Sub
Public ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return True
End Get
End Property
End Class
End Namespace
This problem has exceeded my level of experience so any help will be greatly
appreciated. Thanks in advance for your help.