Writing a web.config file.. question mark problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • penseur11
    New Member
    • Feb 2010
    • 7

    #1

    Writing a web.config file.. question mark problem

    Hi,

    I'm trying to write a new web.config file using VB in ASP.net. I am trying to set access permissions, but it won't let me use the question mark to denote: <deny users="?" /> in the authorization tag. Is there an alternative to this or a different encoding I should be using for this character?

    My specific error: The '?' character cannot be used here.

    Thanks for any replies

    Code:
            'Create file, overwrite if exists
            'enc is encoding object required by constructor
            'It is null, so default encoding is used
            Dim objXMLTW As New XmlTextWriter((MapPath(".") & "\basic\" & fold & "\" & "web.config"), Nothing)
            objXMLTW.WriteStartDocument()
            'Top level (Parent element)
            objXMLTW.WriteStartElement("configuration")
    
            'Child elements, from request form
            objXMLTW.WriteStartElement("system.web")
            objXMLTW.WriteStartElement("auhorization")
            objXMLTW.WriteString("deny users="?"")
            objXMLTW.WriteEndElement()
            objXMLTW.WriteEndElement()
            objXMLTW.WriteEndElement() 'End top level element
            objXMLTW.WriteEndDocument() 'End Document
            objXMLTW.Flush() 'Write to file
            objXMLTW.Close()
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    Originally posted by penseur11
    Hi,

    I'm trying to write a new web.config file using VB in ASP.net. I am trying to set access permissions, but it won't let me use the question mark to denote: <deny users="?" /> in the authorization tag. Is there an alternative to this or a different encoding I should be using for this character?

    My specific error: The '?' character cannot be used here.

    Thanks for any replies

    Code:
            'Create file, overwrite if exists
            'enc is encoding object required by constructor
            'It is null, so default encoding is used
            Dim objXMLTW As New XmlTextWriter((MapPath(".") & "\basic\" & fold & "\" & "web.config"), Nothing)
            objXMLTW.WriteStartDocument()
            'Top level (Parent element)
            objXMLTW.WriteStartElement("configuration")
    
            'Child elements, from request form
            objXMLTW.WriteStartElement("system.web")
            objXMLTW.WriteStartElement("auhorization")
            objXMLTW.WriteString("deny users="?"")
            objXMLTW.WriteEndElement()
            objXMLTW.WriteEndElement()
            objXMLTW.WriteEndElement() 'End top level element
            objXMLTW.WriteEndDocument() 'End Document
            objXMLTW.Flush() 'Write to file
            objXMLTW.Close()
    Wnat's that Question mark, is it really a question mark or some unicode char

    Comment

    • penseur11
      New Member
      • Feb 2010
      • 7

      #3
      In this circumstance, in the xml file, it denotes an anonymous user. Just trying to deny access to anonymous users...but not working when I try to write it into the file.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Look at the output produced...I'm sure that something's invalid that is causing your problem.

        -Frinny

        Comment

        Working...