Solved

error message with response.redirect in a class

Posted on 2007-12-04
6
196 Views
Last Modified: 2013-11-26
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
Comment
Question by:Juliafrazer
  • 2
  • 2
6 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 20402771
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
 

Author Comment

by:Juliafrazer
ID: 20403037
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
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 20403181
could you please try with
HttpContext.Current.Response.Write("admin/menu.aspx");
0
 
LVL 12

Accepted Solution

by:
Sinoj Sebastian earned 500 total points
ID: 20403195
sorry, I mean
HttpContext.Current.Response.Redirect("admin/menu.aspx")
0
 
LVL 25

Expert Comment

by:SStory
ID: 20403548
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now