Showing posts with label FTP. Show all posts
Showing posts with label FTP. Show all posts

Wednesday, June 4, 2014

"HTTP Error 401.3 - Unauthorized" on a unity web player page?

Recently, i involved in a project that has to rush to deploy. Since I work in mobile game company, some games have to be able to run in web browser as well. Unity web player usually would be generated by Unity along with a html page, my task was just to link to that page. So, I uploaded the zipped game content using FileZilla to the Azure server.

To host in IIS 7.5, and allow ".unity3d" to be downloaded is not an issue, what you need to add is new MIME, as explain here.

    
        
           
        
    


Easy, huh? I thought so. Then I browse to my page.
Kaboom!

HTTP Error 401.3 - Unauthorized

You do not have permission to view this directory or page because of the access control list (ACL) configuration or encryption settings for this resource on the Web server.



I just did what's considered normal process, right? As rushing for live, I was cracking my head and wonder what went wrong. Goggling on internet gave me no result which could link error 401.3 with Unity web player. After few hours of trial-and-error, 2 workarounds came into my mind:

1) Permissions and user rights : I have tried to give full-rights on the folder, but failed.
2) Thinking to write code on Asp.net Impersonation, but it invites security concerns.

Suddenly, I found something special:



Hey, why the file name is in green color?
And another googling on this, I found out that:
Green means encrypted, blue means compressed in Windows.

The resolution is:
1) Right-click the file, click "Properties"


2) Click the "Advanced.." button.


3) On the "Compress or Encrypt attributes" section, un-check the "Encrypt contents to secure data"


After the decryption, the text becomes normal black color.


And refresh the browser again, it's ok.


I found out that:
1) when i uploaded the zipped content thru' FileZilla, then this encryption will happen. It must be caused by the FTP issue.
2) when i uploaded the extracted content thru' FileZilla, no issue.


Wednesday, October 22, 2008

10 Developer-must-have apps

While so many bloggers have suggested the usable tools to their audience, how could i lag? Although Scott Hanselman have covered most, and it's a mountain high to climb, let me introduce my favourite top 10 developer-must-have apps:

1) Notepad++ (Language: neutral)
when you need it?
a) View Unix files in Windows platform, especially during Java development.

when you open a come-with-JDK Java file using notepad

when you open it using Notepad++, it's well-formatted

b) Need to probe the _ViewState of ASP .NET web page to see how stateless HTTP retains value after post-back, using base64 decode. (you can try it here)

A normal ASP .NET with its HTML source

Copy the content to Notepad++

Decode it to base64, you can see your state retained

c) Determine Byte-Order-Mark of a file, whether it's saved in following formats: UTF-8, UTF-16, UTF-16 (LE), UTF-32 (BE), UTF-32 (LE), UTF-7, UTF-1, UTF-EBCDIC, SCSU, BOCU-1. And it's exactly .Net method GetPreamble trying to do.

Did you see extra three bytes ahead your file content?

d) it's lightweight, unlike Visual Studio IDE, although Noah Coad might beg to differ.
e) Hey! "All I've mentioned above, other editors have the same features as well". Well, simply I like its UI also.

2) Unlocker (Language: neutral)
when you need it?
a) When you want to delete a file which is being viewed/locked by hidden host. That's nothing more annoyed than this.

b) When a file get locked by your app, especially using class File.IO to write it without closing the stream properly.
c) When you try to delete an old ASP .NET version 1.1 web projects in "Inetpub" that's being locked by IIS.

3) Dependency Walker (Language: native)
when you need it?
a) When you need to determine a EXE is a native exe or .NET managed exe. Why, because you can decompile the source accordingly later :)

A .NET exe

A VB6 dll

b) Of course, find the exe/dll dependencies, as the name implies. When you were in the pre-NET era with only Visual C++/Visual Basic 6 & Package Deployment Wizard, there's no such thing called MSI technology, which can help you to determine most of the dependencies for you.

4) Process Explorer (Language: neutral)
when you need it?
a) When you need to find out what process/apps/service is running secretly. You'll never know your employer have planted a window service for software inventory control on your laptop, until you run it.

b) Check the thread state of a stopped thread, probably due to Timeout of Three-Way Handshake in FTP uploading/downloading, when you suppose to have a multi-threaded app run without stopping FTP upload/download.


5) Microsoft Network Monitor (Language: neutral)

when you need it?
a) When you have written a FTP client app running well on uploading files, but FTP server complaint it never receive. You can show this to prove.


b) When you need to sniff network traffic, especially on FTP since all the commands are transferred thru' Cleartext.

Wow, you can see user-name and password!

6) Reflector (Language: .NET)
when you need it?
a) When you need to re-generate the source that lost and you do not have any source control previously, with the aid from plug-in, FileDisassembler


b) When you need to find the difference between the exe/dll you deployed, with the another aid from plug-in, Diff

7) DebugView (Language: native/.NET)
when you need it?
a) When your app only with issue happens intermittently, you need your app to run in verbose mode using Debug.Print without additional tracer running side-by-side, that might affect the performance, or introduce new bug/maintenance issue. This works well for native app too, using Win32.

8) 7Z (Language: neutral)
when you need it?
a) It supports most of the commercial format, yet without asking you to purchase every time it loads, eg. WinZip, Winrar. Furthermore, it able to compress more to save your disk-space.

b) When you need to find out how the zip file is created. Either SharpZipLib or Windows built-in zipping tool; compression method is either DEFLATE, Implode, or Store. You can get the Host OS and CRC as well.

this zip file is compressed using SharpZipLib with DEFLATE method

this zip file is compressed using Store method

this zip file is compressed using Windows built-in zipping tool

9) Microsoft Virtual PC (Language: neutral)
when you need it?
a) When you wish to be beta tester yet you do not want to jeopardize your existing system.
b) When you found virus, and you need to cultivate it in order to trace the originator, so that... counter-hack!
c) When you need to test your web app in different OS. MS has prepared it for you to use it until January, 2009. Flavours available: Windows XP SP3 with IE6 VHD file, Windows XP SP2 with IE7 VHD file, Windows XP SP3 with IE8 Beta 2 VHD file, and Vista Image with IE7 VHD file. (see: Internet Explorer Application Compatibility VPC Image)
d) When you wish to play around with different *-nix OS.


10) Windiff (Language: neutral)
a) Basically for file compare and directory compare. I have used it since development in Visual C++ 6.0. Though it might not user-friendly, eg, cannot compare in separate panes, cannot compare Unicode/UTF-8 files. But it comes with Visual C++ 6.0 and have been with me so long, I feel hard to say goodbye to it.

Saturday, September 27, 2008

NET 2.0 FtpWebRequest class is far from perfect as self-contained class

In .NET framework 2.0, Microsoft introduced a new class for FTP- FtpWebRequest Class. This class can consider as high-level wrapper class so that developers should no longer need to deal with socket programming and FTP raw command:

  • ABOR - abort a file transfer
  • CWD - change working directory
  • DELE - delete a remote file
  • LIST - list remote files
  • MDTM - return the modification time of a file
  • MKD - make a remote directory
  • NLST - name list of remote directory
  • PASS - send password
  • PASV - enter passive mode
  • PORT - open a data port
  • PWD - print working directory
  • QUIT - terminate the connection
  • RETR - retrieve a remote file
  • RMD - remove a remote directory
  • RNFR - rename from
  • RNTO - rename to
  • SITE - site-specific commands
  • SIZE - return the size of a file
  • STOR - store a file on the remote host
  • TYPE - set transfer type
  • USER - send username
But after applying it in the real application to connect to a Unix FTP server, as a class or dll, with the reference from the sample "FTP Explorer" in MSDN, I found that I have trouble navigating to parent directory, where I would hit error:


System.Net.WebException: The remote server returned an error: (550) File unavailable (e.g., file not found, no access).

(See List of FTP server return codes) but I could do it without any problem using FileZilla. Excluding the problem might come from .NET framework, since FTP is under RFC 959, I was recommended by someone to use the WireShark, a Packet sniffer tool, to check the message sent and received between server and client.


I just realized that the FtpWebRequest class itself could not simply navigate to any path in the server if the default directory is not root path, since with WebRequestMethods.Ftp Members, you only got these raw commands that it wrapped (where's FTP CWD protocol ?):

  • FTP APPE protocol
  • FTP DELE protocol
  • FTP RETR protocol
  • FTP MDTM protocol
  • FTP SIZE protocol
  • FTP NLIST protocol
  • FTP LIST protocol
  • FTP MKD protocol
  • FTP PWD protocol
  • FTP RMD protocol
  • FTP RENAME protocol
  • FTP STOR protocol
  • FTP STOU protocol

(Even using "PrintWorkingDirectory", only empty string returned)

From Mariya Atanasova's Blog:

The above example will bring you to your user's directory and list all the contents there. Now let's say you want to go 2 directories backwards and list the contents there (provided your user has permissions to do that). You close the previous FtpWebRequest and issue a new one with this uri
uri = "
ftp://myFtpUserName:myFtpUserPassword@myFtpUrl/%2E%2E/%2E%2E";
This is equivalent to logging in with your user's credentials and then using cd ../../

But one strange thing: what if user (or even you, the developer) does not know the default directory and current directory? Then you might need WinINet Functions or even worst, go back to socket programming.

p/s: For those who prefer to have hand dirty, there's a free e-book available in scribd: TCP/IP Sockets in C# .

Monday, February 4, 2008

550: Access is denied. Why cannot delete files on FTP server?

FTP is quite popular for transfering the large files since old days. One of the problem that I face previously is this: 550 (foo.txt) : Access is denied, when issuing a delete command from application on client side.

After looking the setting level for the FTP at IIS, I found the user has the right to read/write, but this problem still happens on issuing a delete command. I wonder what went wrong???


A check on the file properties on the server side, I found this file has a read-only attribute!

By modifying the attribute, the delete command is able to delete the file again. I think the application on client side does not have the ability to check the file's attribute, at least for Windows FTP service (Unix should have such ability, using: ls -l ). So the workout is the server side must set the attribute implicitly, through FileAttributes Enumeration.