Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTPHandlers

Status
Not open for further replies.

ChewDoggie

Programmer
Mar 14, 2005
604
US
hello all,

This is complicated but I'll start with the first error I have encountered. Whenever a user would click on a link on our site to open a .wmv file, the user would always get a "file not found" error and the Windows Media player wouldn't launch.

To combat this, I created an httphandler and added this entry in my web.config:

Code:
<httpHandlers>
    <add verb="*" path="*.wmv" type="MyNamespace.MyFileHandler, MyFileHandler"/>
...
</httpHandlers>

Now, whenever the user clicks on a .mwv link, the code in my custom handler executes (as it should) and the file opens in Windows Media Player and life is perfect.

Then......I deployed my app to the test server and it barfed ! The same old errors are occurring again, i.e., "File not Found". I'm not convinced that the custom handler is even executing so I put some code in there to write to a text file, re-compiled and copied to the test server but nothing is being written so I don't think it's executing at all.

If anyone can see anything I'm missing, please don't hesitate to jump in.

Thanks!

Chew


10% of your life is what happens to you. 90% of your life is how you deal with it.
 
which version of IIS?

I don't believe IIS 6 and/or asp.net 2.0 will automatically pick up the WMV extension and process through the asp.net pipeline. You would need to configure IIS to use the asp.net filter for requests ending in WMV. You would need this in addition to your http handler

IIS 7 integrates with asp.net much better than IIS 6. So you can tie into the asp.net pipeline sooner and easier. You could then use the web.config to setup the wmv extension.

Side Note: there are much better ways to trace through your code than hard coding the creation of text files. log4net is an excellent logging library that allows full control from configuration files. This way you do not need to recompile to disable logging.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
Thanks, Jason, for the reply.

It's IIS6/ASP.NET 2.0..., so I'll investigate further about what you said. I changed my tracing as soon as I got in this morning to write to an Event Log via this code in my HttpHandler:

Code:
            if (!EventLog.SourceExists("ChewsApp"))
            {
                EventLog.CreateEventSource("ChewsApp", "Application");
            }
            EventLog EL = new EventLog();
            EL.Source = "ChewsApp";
            EL.WriteEntry("This is a event log entry for the SpecialFileHandler");
            EL.Close();
            EL.Dispose();

but it isn't writing anything, so I suspect that the Handler isn't being hit. There is a log4net.xml file in the solution, I just didn't know what it was there for (once again, my inexperience with web apps raises it's ugly head).

tx again.

Chew

10% of your life is what happens to you. 90% of your life is how you deal with it.
 
log4net.LogManager.GetLogger(type).Debug("your message goes here").

log4net is a logging library, asp.net doesn't matter. the online docs are a great resource.

I would bet that if you configure the virtual directory for this application to use the aspnet_isapi.dll filter to process WMV requests you will resolve your problem.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
added a new application extension for .wmv and it didn't work.

THEN I realized that the "Verify that file exists" checkbox needs to be UNCHECKED, and once I did that, it worked perfectly.

Thanks again Jason !

Chew


10% of your life is what happens to you. 90% of your life is how you deal with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top