[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Request.QueryString

I cannot get my redirect page to actually redirect.  Here is my code for the global.asax page.

Protected Sub Application_Error(ByVal Sender as Object, ByVal e as EventArgs)
  dim strError as string
  strError = Server.GetLastError().ToString()
  Context.ClearError()
  Response.Redirect("defaultError.aspx?Msg=" & Server.UrlEncode(strError))
 End Sub

And here is the code for my defaultError.aspx page.

Sub Page_Load()
   label1.Text = Request.QueryString(Msg)
End Sub


What am i doing wrong, it just doesnt even try to bring across the strError and display it.  the page wont even load, but it used to.

Thanks,
0
NBAIS
Asked:
NBAIS
  • 8
  • 7
  • 2
1 Solution
 
strickddCommented:
Before the "Response.Redirect(" try adding

System.HttpContext.Current. so you will have:

System.HttpContext.Current.Response.Redirect(
0
 
NBAISAuthor Commented:
When i changed the line to what you suggested, it came up with an error saying that

BC30456: 'HttpContext' is not a member of 'System'.

Any other ideas?
0
 
strickddCommented:
I'm sorry, try:

System.Web.HttpContext.Response.Redirect(
0
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.

 
NBAISAuthor Commented:
Still doesnt like me giving error:

BC30469: Reference to a non-shared member requires an object reference.

0
 
strickddCommented:
Just to make sure: it's not actually reaching the defaultErrorPage.aspx, correct?
0
 
NBAISAuthor Commented:
That is correct.
0
 
strickddCommented:
try removing Context.ClearError()
0
 
strickddCommented:
Also, have you tried stepping through your code?
0
 
NBAISAuthor Commented:
Yes I stepped through the code, and it all looks fine, it is just not working for some odd reason.

I just tried to remove the context.clearerror(), didnt change anything.

The page that is erroring is called EnrollmentSummary.aspx
it is coming up with a page cannot be displayed now.

When i take the global.asax file out, and just turn on customererror handling through web.config, my defaultError.aspx loads just fine.

When i try to catch the exception with the global.asax file and pass it through i am getting the error.

0
 
strickddCommented:
Try taking all the error handling code out of the global. Then if that works, try puttting it in on the error page.
0
 
NBAISAuthor Commented:
Already tried to do that, and it didnt work for me.

Everything I have been reading says that I need to catch the error in my global.asax file wtih the Application_error function, then pass the saved variable through to a custom error handling page.

Which is what i am doing, but its not working.

0
 
strickddCommented:
instead of a query string then, try setting it as a Session variable.
0
 
NBAISAuthor Commented:
When i did that, it would load my defaultError page, but it wasnt passing the error across.
0
 
strickddCommented:
come to think of it, i'm not sure you can pass error information like that. You can do response.redirect's with an error code or response.write's to print out the error information. You can also e-mail the error information from the global, but once the global is out of focus, i believe the error information is gone.
0
 
NBAISAuthor Commented:
I was reading in O'Reilly's ASP.NET book that its possible to pass the information. Thats where I am getting confused, is I set it up how they said it should work, and its not.

0
 
garima_sikarwarCommented:
Try this

dim strError as string
  strError = Server.GetLastError().ToString()
  Response.Redirect("defaultError.aspx?Msg=" & Server.UrlEncode(strError))

Server.ClearError()


and also there is a limit of number of characters you can send using Querystring..
So make sure it should not be too long..


0
 
garima_sikarwarCommented:
in web.config

 <customErrors
    mode="Off"
    />
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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