Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

error message with response.redirect in a class

Hi,

I am writing a class that has a sub procedure that checks to see a user's logged in authentication type.
Ie. if they are not an administrtator, then they are redirected back to the home page.
HOwever, i get an error message saying
"Response is not available in this context."

How can i get this to work?

Any clues?

Julia
Imports Microsoft.VisualBasic
Imports System
 
 
 
Public Class PageAccess
    Inherits System.Web.UI.Page
 
    Public Sub access(ByVal intProgrammeID As Integer)
        If intProgrammeID = 7 Or intProgrammeID = 8 Then
            Try
                Me.Response.Redirect("admin/menu.aspx")
            Catch v_exception1 As System.Exception
 
                v_exception1.Message.ToString()
            End Try
 
          
        End If
 
    End Sub
End Class

Open in new window

0
Juliafrazer
Asked:
Juliafrazer
  • 2
  • 2
1 Solution
 
SStoryCommented:
I'm not sure why you would do this when you can do the same thing using authentication in the web.config page.  Then you just define which pages need authenticating and "*" for those that don't.  I'd have to google to find the specifics, but it seems you may be trying to reinvent the wheel.  Is it necessary in your case?
0
 
JuliafrazerAuthor Commented:
I use a colleagues web services for authentication.
In the web config file i have tried using <location> tags with <authorisation> deny etc

but it doesnt work.
0
 
Sinoj SebastianCTO & OpenERP Project managerCommented:
could you please try with
HttpContext.Current.Response.Write("admin/menu.aspx");
0
 
Sinoj SebastianCTO & OpenERP Project managerCommented:
sorry, I mean
HttpContext.Current.Response.Redirect("admin/menu.aspx")
0
 
SStoryCommented:
I would think you'd need to put it in the Page Load event and check for Postback also.
It should work fine then.  From where are you calling it?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now