0

Hi guys I always got this error from my site and it keeps bugging me.I've been trying to figure out the cause of this error but I can't really figure it out.

Here's the stacktrace:

at BasePage.Page_PreInit(Object sender, EventArgs e) 
at System.EventHandler.Invoke(Object sender, EventArgs e) 
at System.Web.UI.Page.OnPreInit(EventArgs e) at System.Web.UI.Page.PerformPreInit() 
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

And on my basepage I only got this code:


Imports Microsoft.VisualBasic

Public Class BasePage
    Inherits System.Web.UI.Page

    Private Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Page.Theme = "Something"
        If (Request.UserAgent.IndexOf("AppleWebKit") > 0) Then
            Request.Browser.Adapters.Clear()
        End If
    End Sub


    Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        If Me.Title = "Untitled Page" Then
            Throw New Exception("Page title cannot be ""Untitled Page"".")
        End If
    End Sub

End Class

According to the stacktrace this always happens on my basepage preinit event.What do you think is the problem here guys?

JaredPar
  • 673,544
  • 139
  • 1,186
  • 1,421
jamal
  • 199
  • 1
  • 5
  • 12

4 Answers4

2

I love guessing games, they are so fun.

Request.UserAgent is null?

slugster
  • 47,434
  • 13
  • 92
  • 138
1

You need to debug the error - run your project in the VS and put breakpoint in the Page_PreInit method. Then execute each line step by step (F10) and you will figure out where and why the error occurres. Also you can use Ctrl+Alt+E to turn on breaking on any thrown exception - this will show you the exact line.

Andrew Bezzub
  • 14,824
  • 6
  • 46
  • 68
0

Likely one of the following values is Nothing / null

  • Request.UserAgent
  • Request.Browser
  • Request.Browser.Adapters

You will need to check these values for Nothing before using them in order to protect yourself against this exception

JaredPar
  • 673,544
  • 139
  • 1,186
  • 1,421
0

It's very difficult to tell without an exact line number, but upon reading the MSDN Documents, your reference to Request.Browser.Adapters looks like it may be causing problems, as MSDN states that this property is used for infrastructure and isn't meant to be accessed directly from your code.

Adam Maras
  • 24,360
  • 5
  • 60
  • 89