Click here to Skip to main content
Click here to Skip to main content

An ASP.NET/AJAX Interface for Utorrent

, 24 Jun 2008
Rate this:
Please Sign up or sign in to vote.
An ASP.NET/AJAX interface for the utorrent application.

Introduction

I recently discovered that the bittorrent application µtorrent contained a Web interface. I eventually got it up and running and thought it was pretty neat. I wanted to customize it and make it my own. So, I searched the Web and came across a set of C# classes that hooked into the official µtorrent Web UI. The original posting is located here. In that same posting, there was also a post about an ASP.NET interface using the C# classes. I tested it out, and thought I could build my own and overcome some of the quirks it had. I also thought it would be a test of what was possible with AJAX.

Background

Getting it up and running should be fairly straightforward. What is needed is IIS, .NET 3.5, and a recent version of µtorrent with the Web UI enabled. If you have trouble running the site, you may also need the AJAX Control Toolkit. There is also a Windows service that gathers stats for each of the torrents.

Screenshots

Settings.PNG

Figure 1. The Settings page that is displayed when the Settings link is clicked, on first run, or when there is an error within the configuration.

Main.PNG

Figure 2. The primary page that is displayed. It contains the list of torrent types in a listbox, the torrents in a GridView, a tab control with a formview for general information and a GridView listing the files. On this page is a DropDownList to change the site theme, a link to the settings, and a link to view the logs. Also on this page is a section to start new torrents from either a URL or from a file.

General.PNG

Figure 3. After clicking the Details link from the torrent GridView, the general tab will list the information about a torrent.

Files.PNG

Figure 4. After clicking the Details link from the torrent GridView, the files tab will list the files and their status of a torrent.

Logs.PNG

Figure 5. The log viewer will list all of the information about the logs. The GridView features a DropDownList for each field that can be used to filter the logs.

Stats.PNG

Figure 6. The Stats tab contains a dynamically updated graph of the stats of the current torrent. The X and Y axis are selected by the two ListBoxes above the graph. A third-party graphing utility, SasqChart, was used for the graphs.

Using the Code

To get started, copy the files to your server's directory. Make sure that the directory is configured as an application. Open your Web browser and point it towards the URL of the directory you created. The first time the application runs, it will detect that the settings are invalid and will prompt you to enter them. Once completed, click the Save button to commit the changes. If you wish to encrypt the information within the web.config, you can click the Link Button on the Settings page to do that. If you click it and go through the confirmation, the appSettings section of the web.config will be encrypted.

I decided to use the HTTP Compression features of this project in the hopes of speeding things up a bit.

I also added in an extremely simple HttpModule to handle the security since I did not want to mess with or rely on the IIS security. In a shared hosting environment, you also might not have easy access to that. The web.config contains an accesslist setting that is a comma delimited string of the IP addresses that can access the site. If this is not needed, then all you have to do is remove the SecurityHttpModule entry in the web.config or leave the entry on the Settings page blank.

I have updated this article to include a Windows service that will gather stats for each of the torrents. The installation of the service is very simple. The application can run as either a console application or as a Windows service. I came up with the idea from this Code Project article. To run it as a console application, run the application without any arguments. To run the application as a service, run it with a –service argument. To remove the service from the system, run the application with a –removeservice argument.

To install, extract the compiled binaries and the application configuration file to a directory. Set up the application configuration file as needed. Install the application as a service (run once with a –service argument) or setup a Task Scheduler task to execute the application without any arguments.

One last option to consider. The performance of the site can be greatly improved by setting the debug setting in the web.config to false. This is mainly due to the AJAX Control Toolkit and the difference in the scripts it sends to the client.

There are still some quirks, but overall, it gets the job done; whatever that may be!

Features

Here is a list of some of the features of this project:

  • Uses AJAX to display the data from µtorrent, providing a simple Web interface that is accessible by most browsers.
  • The page is updated with UpdatePanels by an AJAX Timer control.
  • The GridViews support paging and sorting from within the Update Panel.
  • New torrents can be added via new files or via URLs.
  • An Update Progress Control is used to display a Loading... animation in the top left corner. It can be configured with stylesheets or themes.
  • I have imported all of the auto-format themes from Visual Studio into *.theme files to support Website theming.
  • The logviewer features a GridView with a neat feature - filtering. The distinct values of each column are displayed in a DropDownList in the column header that can be used to filter the data in the GridView.
  • A logging utility was created to facilitate the logging. Logs can be in either a tab delimited text file or an XML file. I have included an XSLT file to transform the XML log file from being element based to attribute based; some controls (GridView, etc.) prefer attribute based, others (TreeView) prefer element based.
  • This would be needed if you want to bind the log data to other control types.
  • A very simple security utility was created that will filter requests by IP Address.
  • A method of getting distinct values from a column in a datatable was created.
  • A historical stats history of each torrent. You can choose the X and Y axis on demand.

Points of Interest

None really yet. Comments and criticisms are welcome.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

matts_junk

United States United States
All around cool guy.

Comments and Discussions

 
Generalnot running in 2005 Pinmembergulam husain ansari2-Jan-10 0:55 
Generalupdated article and code coming soon! Pinmembermattsrebatespam22-Jun-08 5:38 
QuestionNeed to install uTorrent PinmemberMehdi Payervand26-Apr-08 21:23 
GeneraluTorrent WebUI PinmemberReuben200518-Mar-08 10:31 
QuestionScreenshots? PinmemberNathan Moinvaziri12-Jan-08 21:04 
AnswerRe: Screenshots? Pinmembermattsrebatespam15-Jan-08 13:47 
GeneralNeat PinmemberBen Daniel8-Jan-08 16:45 
GeneralRe: Neat Pinmembermattsrebatespam9-Jan-08 6:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 24 Jun 2008
Article Copyright 2008 by matts_junk
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid