Issues with Masterpage loading dynamically

Posted on 2007-10-01
Last Modified: 2013-11-07
I have an application, that needs to have the masterpage file to be dynamically loaded at runtime.

Based on each portal_id passed, i need to query the database for the corresponding masterpage file and use it. here is the back end code

Partial Class UserProfileLogin
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Overrides Sub OnPreInit(ByVal e As EventArgs)

        Session("PORTAL_ID") = Request.QueryString("PortalID")
        Dim objSiteConfiguration As New DomainDALTableAdapters.objSiteConfigurationTableAdapter
        Dim masterfile As String = objSiteConfiguration.RetrieveMasterPage(CInt(Session("PORTAL_ID")))
        If Not masterfile.Equals(String.Empty) Then
            MyBase.MasterPageFile = masterfile
        End If
    End Sub

End Class

I get the following error

Illegal characters in path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Illegal characters in path.

Any thoughts !!!
Question by:TECH_NET
    LVL 7

    Accepted Solution

    See this article,

    You have to do some configuration on web.config
    LVL 5

    Expert Comment

    Try stepping through the project and tell us what the value for the masterfile is. We can assist you from there. Its most likely just the path no being properly constructed.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    728 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

    18 Experts available now in Live!

    Get 1:1 Help Now