Security Exception while accessing XML file data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssnaik84
    New Member
    • Aug 2009
    • 149

    Security Exception while accessing XML file data

    Hello,

    I have hosted a website on GoDaddy.com. It's a share hosting. I am using XML file as a database. That means, I am reading and writing data into XML file instead of regular RDBMS (MySQL, MS SQL). I am reading XML data into DataSet and manipulate it and save the changes again to XML file.

    It works fine on my local machine.. but not working on GoDaddy server.. I am getting security exception..

    Code:
    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
    
    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
    Stack Trace is..

    Code:
    [SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
       System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
       System.Security.CodeAccessPermission.Demand() +58
       System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +644
       System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +64
       System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +77
       System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +54
       System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) +74
       System.Threading.CompressedStack.runTryCode(Object userData) +70
       System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) +0
       System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) +108
       System.Xml.XmlTextReaderImpl.OpenUrl() +186
       System.Xml.XmlTextReaderImpl.Read() +208
       System.Xml.XmlTextReader.Read() +15
       System.Xml.XmlReader.MoveToContent() +64
       System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving) +306
       System.Data.DataSet.ReadXml(String fileName) +70
       defaultPage.ReadImageXML() in Default.aspx.cs:57
       defaultPage.SetDefault() in Default.aspx.cs:41
       defaultPage.Page_Load(Object sender, EventArgs e) in Default.aspx.cs:33
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +50
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
       System.Web.UI.Page.ProcessRequest() +80
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
       System.Web.UI.Page.ProcessRequest(HttpContext context) +49
       ASP.default_aspx.ProcessRequest(HttpContext context) in App_Web_mi4hgfcc.0.cs:0
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
    Let me know where I am going wrong.. and how to resolve this issue.. Thanks..
    -- Swapnil

    NB. It's shared hosting.. hence, i can not modify machine.config
  • sanjib65
    New Member
    • Nov 2009
    • 102

    #2
    Hosting problem

    Actually this security concerns raised because it's a share hosting. Otherwise Data manipulation through XML should work fine.
    Sometimes, due to the incapability of Hosting Company many errors could come. In my experience I faced some hosting company who can not run PHP properly...:)
    So it's wise, always, to choose good hosting company.

    Comment

    • semomaniz
      Recognized Expert New Member
      • Oct 2007
      • 210

      #3
      This is because you do not have write access to the folder that contains you xml file. you need to contact godaddy and ask them to give you permission on one of the folders to write files. This should fix you problem. Make sure u have the xml file inside the folder that has the write permission set.

      Comment

      Working...