views:

481

answers:

5

(Extremely noob question coming up)

I have

  • an ashx file,
  • Visual Studio 10,
  • no knowledge at all about C# ASP.NET

What is the proper way to compile and run this?

Context

The ashx file in question can be found in this zip, and is a demo application for a Tetris AI competition. It is a very enticing idea even if it depends a great deal on luck, and I thought I might use the occasion to learn a new language.

+3  A: 

An ashx file is a just a generic HTTP handler, so the easiest way to get this working is to create a new Web Site in the File menu, and just add the Handler.ashx file to the website root directory.

Then, just run the site (F5) and browse to "YourSite/Handler.ashx".

John Rasch
+2  A: 

You need to deploy it to an IIS server that has the proper .NET framework installed and that should be it.

If you are trying to get it working locally, create a web site project in visual studio, go to "add existing items" in solution explorer, and locate your ashx. Then click the play button (or press F5) to compile and run it.

Good luck!

Josh Stodola
+2  A: 

An ASHX file is like an ASPX file, but it's a handler. That means it doesn't respond back with HTML by default, and can therefore "handle" otherwise unhandled file types, but it's not necessarily tied to that meaning. In this case, you'll only be presenting the response

position=8&degrees=180

...to a posted board and piece. So you don't need HTML, so you want an ASHX.

You can make .ashx files the startup page in your project, just the same as .aspx pages. If I were writing a HelloUser.ashx page, I might set it as the start page, with some parameters passed in as querystrings or something.

You're probably going to want a test harness that posts a board / piece to your service, and that could be any kind of project. Command line program, website, test class run through NUnit, whatever. There's a lot of logic to keep track of beyond the "player" logic.

If you need a more detailed answer than that, SO might not be the place for this question. But I wish you all kinds of luck with this - it's an interesting problem.

dnord
Thanks for the details. The hardest problem was actually just to get it running :)
Johannes Hoff
A: 

You're missing an some form (an ASPX file maybe) that goes with this handler. It looks like this thing probably handles some AJAX request from another page.

It's expecting 2 pieces of data with the request as well:

string board = context.Request.Form["board"];
string piece = context.Request["piece"];

You could reverse engineer the form that this is for, but it will probably take some time to get that board array right.

free-dom
The data actually comes from another application, not a form (see link). Thanks for taking the time, though.
Johannes Hoff
A: 

For quick information on httphandler Click Here

Neil