468,761 Members | 1,802 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,761 developers. It's quick & easy.

Security Exception while accessing XML file data

ssnaik84
149 100+
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..

Expand|Select|Wrap|Line Numbers
  1. 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.
  2.  
  3. 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.
  4.  
  5.  
Stack Trace is..

Expand|Select|Wrap|Line Numbers
  1. [SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
  2.    System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
  3.    System.Security.CodeAccessPermission.Demand() +58
  4.    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
  5.    System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) +64
  6.    System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +77
  7.    System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +54
  8.    System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver) +74
  9.    System.Threading.CompressedStack.runTryCode(Object userData) +70
  10.    System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) +0
  11.    System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state) +108
  12.    System.Xml.XmlTextReaderImpl.OpenUrl() +186
  13.    System.Xml.XmlTextReaderImpl.Read() +208
  14.    System.Xml.XmlTextReader.Read() +15
  15.    System.Xml.XmlReader.MoveToContent() +64
  16.    System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving) +306
  17.    System.Data.DataSet.ReadXml(String fileName) +70
  18.    defaultPage.ReadImageXML() in Default.aspx.cs:57
  19.    defaultPage.SetDefault() in Default.aspx.cs:41
  20.    defaultPage.Page_Load(Object sender, EventArgs e) in Default.aspx.cs:33
  21.    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
  22.    System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
  23.    System.Web.UI.Control.OnLoad(EventArgs e) +99
  24.    System.Web.UI.Control.LoadRecursive() +50
  25.    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
  26.    System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
  27.    System.Web.UI.Page.ProcessRequest() +80
  28.    System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
  29.    System.Web.UI.Page.ProcessRequest(HttpContext context) +49
  30.    ASP.default_aspx.ProcessRequest(HttpContext context) in App_Web_mi4hgfcc.0.cs:0
  31.    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
  32.    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
  33.  
  34.  
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
Dec 13 '09 #1
2 2746
sanjib65
102 100+
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.
Dec 13 '09 #2
semomaniz
210 Expert 100+
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.
Dec 14 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Dave | last post: by
1 post views Thread by The Eeediot | last post: by
3 posts views Thread by abcd | last post: by
3 posts views Thread by Ken Varn | last post: by
2 posts views Thread by Budhi Saputra Prasetya | last post: by
reply views Thread by sunoj | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.