ASP.NET problem with XML file


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 15 of 15

Thread: ASP.NET problem with XML file

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Posts
    8

    ASP.NET problem with XML file

    Hello,

    We have a web application and our online help is provided through an xml help file. When we post our web application on our test server, all PC's are able to access and display the help correctly. When users try to access the help xml file from the live production website, the help file displays correctly on some PC's and other PC's get a file not found error.

    We know the file is existing in the correct location because even on a PC that is getting the file not found error, we are able to direclty type in the address in the address bar in IE and it is displaying the XML file.

    The problem is occurring only when users try to access it from the live application site. Only some users get the file correctly, others get the file not found error.

    We tried verifying the XML parser versions, security settings on the PC's that are getting this error but nothing really works. For all users, the test server works well.

    Please help me if you have any ideas. Why would I get a file not found error on a live site and not on a test site.

    Any help will be greatly appreciated.

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    How do you display the XML help file from your code? Can we assume this file is on the web server?

    If the application operates properly in your test environment I would say that there's likely a permissions problem. It might help to know what type of authentication your web app is configured for.
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  3. #3
    Join Date
    Oct 2005
    Posts
    8
    pclement, Thank you very much for your reply. Please keep replying if you have any other ideas or suggestions.

    The XML help file is displayed as a Document Tree. And yes, the help.xml file is available on the live web server.

    I really dont know if it is an authentication problem. The xml help file comes up ok from some aspx pages even on PC's that get the "File not Found" error while on other pages it doesnt work.

    The PC's on which the xml help file works without any problems, they do not get the "File not Found" error no matter from which aspx page they access the help file.

    I tried matching up the Internet Options and other Security settings from PC's which doesnt have this problem but nothing worked.

  4. #4
    Join Date
    Dec 2003
    Posts
    2,750
    If the XML file is on the web server then I would suspect that some users don't have sufficient permissions to access that file or the folder where the file is located. Is your web app configured for Integrated Windows authentication?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  5. #5
    Join Date
    Oct 2005
    Posts
    8
    I'm not sure what kind of authentication we are using. I just joined this place and the programmers who have been here said they are not sure what authentication is used. How can I check what kind of authentication is being used?

    Also if some users dont have sufficient privileges to access the xml help file or the Help folder, how come all users are able to access the xml help file from some aspx pages?

    The xml help file shows up in an aspx page. It works fine from some pages for all users. From some other pages, some users get the following error:

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    The resource cannot be found.
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

    Requested Url: /Help/Help.aspx


    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

    Some users do not get this error at all no matter from which page they access the xml help file.

    What I'm unable to understand is how come the exact same folder structure works on the test server and not on the live server.

    Some users get the above error while trying to access the xml help file from some aspx pages. Other users do not get the error at all on any page and are able to access the help xml file without any problems.

  6. #6
    Join Date
    Feb 2004
    Posts
    126
    As Paul adviced try checking what Authentication it has by checking the file permission etc..But the error seems as if the file you are trying to view is not even on the server..What you can try again is try adding YourComputername\ASPNET acct to the file or folder.
    BY the way are you using a Webcontrol to display the XML?
    Patrick

  7. #7
    Join Date
    Oct 2005
    Posts
    8
    Hello najicoder,

    Thanks for your reply. We are not using any custom controls to display the xml help file. We are just using an aspx page. Also we are not using any kind of machine authentication or user authentication. Still some users get the error and some dont. Even for users who get the error, the xml help file displays correctly from some pages.

    Also the error we are getting is:

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    The resource cannot be found.
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

    Requested Url: /Help/Help.aspx


    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

    So if you see closely, it is not able to find the Help.aspx page and not the xml help file itself.

    Like I said, both the aspx page and the xml help file are on the live web server. Some users get the error and others dont get it.

    Please help with any possible suggestions and/or solutions.

  8. #8
    Join Date
    Dec 2003
    Posts
    2,750
    The application security level is configured in IIS (Internet Services Manager applet in the Adminitrative Tools folder in Control Panel). Right click on your application after running the applet and select Properties. Click on the Directory Security tab and then the Edit button. One or more of the Authentication Methods should be selected.

    You will probably need to verify the security on the Help folder. If the folder exists and Help.aspx is present then a permissions problem would still be my first guess. I'm assuming you're navigating to that page using Response.Redirect or Server.Transfer?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  9. #9
    Join Date
    Oct 2005
    Posts
    8
    Hi pclement,

    Thanks for letting me know how to check the security setup. Also below is the detailed code of how we are actually calling the xml help file and the help.aspx page. Please take time to go through it. I appreciate all your help.

    A part of the code in our main.aspx page is below. This main.aspx page is just a welcome page and anybody can get to it.

    main.aspx

    <html>
    <head>
    <script language="javascript" type="text/javascript" src="portalscripts.js"></script>
    </head>
    <body>
    <TABLE id="HelpLink" cellSpacing="0" cellPadding="0" width="100%" border="0">
    <TR>
    <TD align="right"><FONT face="Verdana"><A onmouseover="this.style.textDecoration='underline'; this.style.cursor='pointer'"
    style="FONT-WEIGHT: bold; COLOR: blue" onclick="helpPage('homacc');" onmouseout="this.style.textDecoration='none';">Help/FAQ</A></FONT>
    </TD>
    </TR>
    </TABLE>
    </body>
    </html>

    You will notice that we are including a .js (portalscripts.js) file and calling a function (helpPage) with in that file.

    Our portalscripts.js file looks like this

    portalscripts.js

    function helpPage(item)
    {
    if(is_ie){
    msgWindow = window.open('','Help','width=560,height=347');
    msgWindow.location.href = 'http://' + document.domain + '/Help/Help.aspx?item=' + item + '';
    if (msgWindow.opener == null) msgWindow.opener = self;
    msgWindow.focus();
    }
    else if (is_nav || is_moz)
    {
    msgWindow = window.open('','Help','width=560,height=350');
    msgWindow.location.href = 'http://' + document.domain + '/Help/NetscapeHelp.aspx?item=' + item + '';
    if (msgWindow.opener == null) msgWindow.opener = self;
    msgWindow.focus();
    }
    }

    In the above code you will notice after checking the browser of the user, we are calling the help.aspx page.


    Our Help.aspx page looks like this:

    Help.aspx

    Imports System.Xml.XPath
    Imports System.Xml.Xsl
    Imports System.Text
    Imports System.IO
    Imports System.Xml

    Public Class Help
    Inherits BasePage
    Private xmlPath As String
    Private app As String
    Private item As String
    Protected WithEvents treePane As System.Web.UI.HtmlControls.HtmlGenericControl
    Protected WithEvents tbText As System.Web.UI.WebControls.TextBox
    Protected WithEvents btnPrint As System.Web.UI.WebControls.LinkButton
    Protected WithEvents contentPane As System.Web.UI.HtmlControls.HtmlGenericControl

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    If Not (Request.Params("item") Is Nothing) Then
    item = (Request.Params("item"))
    End If
    Try
    xmlPath = Server.MapPath("Help.xml")

    TransformTree()
    If Not (item = String.Empty) Then
    TransformItem()
    End If
    Catch ex As Exception
    contentPane.InnerHtml = "<table ID='Table101' cellSpacing='0' cellPadding='0' border='0'><tr><td align='center' valign='middle'><br><br><FONT face='Verdana' size='2'>There has been an error creating the page.<br>Please try again or contact the webmaster for assistance.</FONT></td></tr></table>"
    End Try

    Dim s As String = "<SCRIPT language=javascript> setPage('" & item & "');</SCRIPT>"
    Page.RegisterStartupScript("growPages", s)
    End Sub

    Private Sub TransformTree()
    Dim sw As New StringWriter
    Dim doc As New XmlDocument
    doc.Load(xmlPath)
    Dim root As XmlElement = doc.DocumentElement
    Dim mynode As XmlNode
    mynode = root.SelectSingleNode("descendant::area/application/page/item[@id='" & item & "']")
    mynode = mynode.ParentNode.ParentNode
    Dim xmlDoc As New XmlDocument
    xmlDoc.LoadXml(mynode.OuterXml)
    Dim trans As New XslTransform
    trans.Load(Server.MapPath("Help-treePane.xslt"))
    trans.Transform(xmlDoc, Nothing, sw, New XmlUrlResolver)
    treePane.InnerHtml = sw.ToString

    End Sub

    Private Sub TransformItem()
    Dim sw As New StringWriter
    Dim doc As New XmlDocument
    doc.Load(xmlPath)
    Dim root As XmlElement = doc.DocumentElement
    Dim mynode As XmlNode
    mynode = root.SelectSingleNode("descendant::area/application/page/item[@id='" & item & "']")
    Dim xmlDoc As New XmlDocument
    xmlDoc.LoadXml(mynode.OuterXml)
    Dim trans As New XslTransform
    trans.Load(Server.MapPath("Help-contentPane.xslt"))
    trans.Transform(xmlDoc, Nothing, sw, New XmlUrlResolver)
    tbText.Text = mynode.Item("text").InnerXml
    contentPane.InnerHtml = sw.ToString
    End Sub

    Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

    Dim s As String = "<SCRIPT language=javascript>printWindow = window.open('','Print','width=560,height=650,resizable=yes');"
    s = s & "printWindow.location.href = '" & Application("AppPath") & "/Help/Print.aspx?item=" & item & "';"
    s = s & " if (printWindow.opener == null) printWindow.opener = self;"
    s = s & "printWindow.focus();</SCRIPT>"

    Page.RegisterStartupScript("showHelp", s)
    End Sub
    End Class

    That is the whole thing. This very same structure works in our test server for all users.

    It works for some users and not other users on our live web site. Like I said in my previous posts, even for users who get the "The resource not found" errror, the help file does come up ok from some aspx pages. The problem occurs only from some other aspx pages. Some users does not have any problem accessing the help.aspx page and the xml help file from any page on the webserver.

    Thanks for all your help.

  10. #10
    Join Date
    Oct 2005
    Posts
    8
    Hello again pclement,

    I checked the security settings for our web app. It is as follows:

    It allows Anonymous Access. And it uses Integrated Windows Authentication.

    Nothing else.

    Thanks.

  11. #11
    Join Date
    Dec 2003
    Posts
    2,750
    You're kind of losing me here on where it works and doesn't work. This statement is confusing:

    Like I said in my previous posts, even for users who get the "The resource not found" errror, the help file does come up ok from some aspx pages.

    Does this mean that the page can be launched from a page in the application but fails in a different page of the application for the same user?

    Did you verify that everyone has access to the Help folder?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  12. #12
    Join Date
    Oct 2005
    Posts
    8
    Hi pclement,

    your question:

    Does this mean that the page can be launched from a page in the application but fails in a different page of the application for the same user?

    my answer:

    Yes. You got it. Users who are getting the "The resource not found" error are able to launch the help.aspx page from some pages in the application and not from other pages.

    Users who do not get the error, are able to launch the help.aspx page from all pages in the application.

    All users are able to launch the help.aspx page from all pages in the application on the test server.

    your 2nd question:

    Did you verify that everyone has access to the Help folder?

    my answer:

    Yes. All users have access to the Help folder. We are just using anonymous login and Windows Integrated Authentication. Nothing else.

  13. #13
    Join Date
    Oct 2005
    Posts
    8
    Hello everybody,

    Seems like I found what the problem is!!

    In our .js file, we are using 'http://' + document.domain + '/Help/help.aspx' to navigate to the help.aspx file in the Help folder.

    For some reason that I dont understand, on some PC's, the document.domain is not being interpreted correctly.

    For testing purposes, I removed the document.domain and hard coded the whole path to the Help folder and the help.aspx page.

    That worked like a champ.

    I still wonder why document.domain would be a problem on some PC's and not others. Could it be a javascript version issue?

    I'm using Windows XP Professional with IE 6.0.

    Could anybody tell me how to check what version of javascript is running on a PC?

    Thanks for all your help and suggestions.

  14. #14
    Join Date
    Dec 2003
    Posts
    2,750
    Well I have to admit I only gave a cursory glance at the JavaScript and Document.Domain and I can't explain the behavior. Does it return nothing or something different than the actual domain name?
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  15. #15
    Join Date
    Feb 2004
    Posts
    126
    Well good you got the error and fixed it as i mentioned before the error seemed as if the right URL/Page(resources) weren't available.
    Patrick

Similar Threads

  1. wav file fade in out help
    By jase_dukerider in forum C++
    Replies: 2
    Last Post: 04-14-2005, 07:48 PM
  2. Why use XML?
    By Brian in forum XML
    Replies: 5
    Last Post: 01-10-2003, 08:39 PM
  3. Replies: 0
    Last Post: 09-02-2002, 06:11 AM
  4. XML files vs Database
    By Mansoor in forum XML
    Replies: 8
    Last Post: 08-23-2002, 04:35 PM
  5. Problem creating element in XML file
    By Gia in forum ASP.NET
    Replies: 3
    Last Post: 06-20-2001, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center