Editor trying to save to a file that's nowhere referenced in the aspx code.

Last post 10-10-2006, 12:30 PM by pgymjp. 1 replies.
Sort Posts: Previous Next
  •  10-10-2006, 12:22 PM 23456

    Editor trying to save to a file that's nowhere referenced in the aspx code.

    I am perplexed! I have taken the example editHtml.aspx file and massaged it to my own needs. I've renamed the file to editFile.aspx. This involved changing:
     
    Editor1.LoadHtml("document.htm") to Editor1.LoadHtml(Request.Querystring("page")).
     
    The page loads fine from what I feed the editor in the path parameter. The problem is in saving. The path variable gets URL encoded so that a file named "/sitecontent/byron.inc" gets displayed as URL:
     
    As I said I can get the editor to load this fine. My code to save it is as follows:

    Public Sub Submit(sender As object, e As System.EventArgs)
      Dim strFileName As String = Request.Querystring("path")
      strFileName = strFileName.Replace("%2F", "/")
      strFileName = strFileName.Replace("%2E", ".")
      Editor1.SaveFile(strFileName)
    End Sub
     
    You can see that I'm replacing the URL encoding with the "/" and "." of the filename to be edited. The error I get from ASP.NET is:

    Access to the path "E:\web\users\mnmaao.org\admin\vb\document.htm" is denied.
    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.UnauthorizedAccessException: Access to the path "E:\web\users\mnmaao.org\admin\vb\document.htm" is denied.
     
    What's driving me insane is that NOWHERE in the code do I reference document.htm!! Not ONE place. Why is the editor trying to save this file instead of /sitecontent/byron.inc!? Oh, and I'm also seeing a textbox control that I've removed from the code. I have no idea why that's showing up either. I have flushed my browser's cache, history, etc to try to force a clean load. It's almost as if what loads is a combination of what I've edited and what the file originally was.
     
    Here's the complete code of my editFile.aspx file:
    <%@ Page Language="VB" ValidateRequest="False" %>
    <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <html>
        <head>
      <title>ASP and ASP.NET WYSIWYG Editor - Edit Static Html Example </title>
      <link rel="stylesheet" href="../example.css" type="text/css" />
     </head>
     <body>
            <form runat="server">
       <table border="0" cellpadding="0" cellspacing="0">
        <tr>
         <td width="20" nowrap></td>
         <td valign="top" width="760">
          <CE:Editor id="Editor1" EditorWysiwygModeCss="../example.css" EditCompleteDocument="true" AllowPasteHtml="false" ThemeType="Office2003_BlueTheme" runat="server" ></CE:Editor><BR>
          <asp:Button id="btnUpdate" onclick="Submit" Runat="server" Text="Submit"></asp:Button><br />
         
         </td>
        <tr>
       </table>   
      </form>
     </body>
    </html>

    <script runat="server">
     Public Sub Page_Load(sender As object, e As System.EventArgs)
     
      If Page.IsPostBack Then
       Dim strFileName As String = Request.Querystring("path")
       strFileName = strFileName.Replace("%2F", "/")
       strFileName = strFileName.Replace("%2E", ".")
       Editor1.SaveFile(strFileName)
      Else
       Editor1.LoadHtml(Request.Querystring("path"))
      End If
      
     End Sub
     public Sub Submit(sender As object, e As System.EventArgs)
      Dim strFileName As String = Request.Querystring("path")
      strFileName = strFileName.Replace("%2F", "/")
      strFileName = strFileName.Replace("%2E", ".")
      Editor1.SaveFile(strFileName)
     End Sub
    </script>
     
     
    The stack trace ASP.NET returns is:
    Stack Trace:
    [ArgumentNullException: Value cannot be null.
    Parameter name: path]
       CuteEditor.EditorUtility.ProcessPhyPath(HttpContext context, Control ctrl, String path) +193
       CuteEditor.Editor.a(String A_0) +45
       CuteEditor.Editor.LoadHtml(String _filename) +10
       ASP.cuteSoftEdit_aspx.Page_Load(Object sender, EventArgs e) +168
       System.Web.UI.Control.OnLoad(EventArgs e) +67
       System.Web.UI.Control.LoadRecursive() +35
       System.Web.UI.Page.ProcessRequestMain() +750
     
    Any help would be greatly appreciated!!
    Thanks,
    Jeff
     
    BTW: what does the "<%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>" line mean?
  •  10-10-2006, 12:30 PM 23458 in reply to 23456

    Re: Editor trying to save to a file that's nowhere referenced in the aspx code.

    Correction:
     
    In the line: "Editor1.LoadHtml("document.htm") to Editor1.LoadHtml(Request.Querystring("page"))." towrds the beginning of my post, the code correctly is: "Editor1.LoadHtml("document.htm") to Editor1.LoadHtml(Request.Querystring("path"))".
     
    Typo on my part.
View as RSS news feed in XML