Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's the difference insecurity a browser and a web client?
    text
    copied!<p>I have an ASP.Net page that does some file IO work. When I request it from a web browser, namely chrome, it succeeds, but when I request it from a WebClient instance in my application it gives me a 'System.Security.SecurityException'. Are there significant differences in the two requests? What do I need to do know about code-access-security in order to get this page to work from within my Web Client? </p> <p></p> <p>Here is the raw fiddler requests and responses:</p> <p><strong>Browser Request:</strong></p> <pre><code>GET http://192.168.1.89/QuickCutConsoleDataProvider/UpdateItemFiles.aspx HTTP/1.1 Host: 192.168.1.89 Proxy-Connection: keep-alive Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 </code></pre> <p><strong>Browser Response:</strong></p> <pre><code>HTTP/1.1 200 OK Via: 1.1 PHOBOS Connection: Keep-Alive Proxy-Connection: Keep-Alive Content-Length: 35189 Date: Tue, 14 Dec 2010 14:08:46 GMT Content-Type: application/zip Server: Microsoft-IIS/7.5 Cache-Control: private X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET ... Binary Content ... </code></pre> <p><strong>Web Client Request:</strong></p> <pre><code>POST http://192.168.1.89/QuickCutConsoleDataProvider/UpdateItemFiles.aspx?Guid=e30e1826-3d96-4769-a540-acd911cccf02 HTTP/1.1 Content-Type: multipart/form-data; boundary=---------------------8cd697dcbf75ed4 Host: 192.168.1.89 Content-Length: 303 Expect: 100-continue -----------------------8cd697dcbf75ed4 Content-Disposition: form-data; name="file"; filename="Catalog.xml" Content-Type: application/octet-stream &lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt; &lt;catalog version="1.0"&gt; &lt;items /&gt; &lt;/catalog&gt; -----------------------8cd697dcbf75ed4-- </code></pre> <p><strong>Web Client Response (exception):</strong></p> <pre><code>HTTP/1.1 200 OK Via: 1.1 PHOBOS Connection: Keep-Alive Proxy-Connection: Keep-Alive Content-Length: 1244 Date: Tue, 14 Dec 2010 14:12:34 GMT Content-Type: text/xml; charset=utf-8 Server: Microsoft-IIS/7.5 Cache-Control: private X-AspNet-Version: 2.0.50727 X-Powered-By: ASP.NET &lt;error type="System.Security.SecurityException"&gt; &lt;message&gt;Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.&lt;/message&gt; &lt;stack-trace&gt;&lt;![CDATA[ at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System.IO.File.GetLastWriteTimeUtc(String path) at Ionic.Zip.ZipEntry.Create(String nameInArchive, ZipEntrySource source, Object arg1, Object arg2) at Ionic.Zip.ZipEntry.CreateFromFile(String filename, String nameInArchive) at Ionic.Zip.ZipFile.AddFile(String fileName, String directoryPathInArchive) at Ionic.Zip.ZipFile.AddFile(String fileName) at MyApplication.UpdateItemFiles.GetUpdateContent(XDocument a_xManifest, Stream[] a_arrExtraContent) in C:\Software\MyApplication\Alpha\Web Interface\UpdateItemFiles.aspx.cs:line 282 at MyApplication.UpdateItemFiles.Page_Load(Object sender, EventArgs e) in C:\Software\MyApplication\Alpha\Web Interface\UpdateItemFiles.aspx.cs:line 31]]&gt;&lt;/stack-trace&gt; &lt;inner-exception&gt;null&lt;/inner-exception&gt; &lt;/error&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload