0

I have an issue with my ashx handlers which are triggered via an update panel postback and a javascript call.

Long story short, there are two handlers in the application. Regardless of what URL I call, I always end up in the same handler (the older one) and never in the newer required one.

I can not figure how this can happen as the URL appears to be correct therefore I am leaning to a configuration issue.

Any ideas anyone - this is starting to fry my nut?

Cheers

Code below:

C#:

string encryptedQuerystring = StringFunctions.EncryptQueryString(string.Format("productId={0}", CurrentProduct.Id));

        string js = "$(function () {ProductManager.ExportProductExcel('../../Handlers/ProductExportExcel.ashx" + encryptedQuerystring + "');});";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "GenerateProductExport", js, true);

Javascript:

ExportProductExcel: function (url) {
    window.location = url;
    alert(window.location);
Morn
  • 191
  • 1
  • 4
  • 14
  • What is the full desired path, and the current actual path produced? When you say "the URL appears correct", is that from the alert? Have you stepped through the js in a debugger? – Joe Carr Feb 01 '13 at 23:37
  • @Joe Carr - the location that gets alerted is http://localhost/handlers/productexportexcel.ashx? ..... (add query string here). As I say it's correct however a different ashx runs up. – Morn Feb 02 '13 at 08:58
  • What is the path of the handler which is executed? – Joe Carr Feb 02 '13 at 18:22
  • As above but ../excelexport.ashx.... Can there only be one handler in a directory?. – Morn Feb 03 '13 at 09:14
  • You can any desired number of handlers in a directory. Have you used fiddler to check all accesses of the 2 handler urls? Are you trying to convert all the code to call the newer handler ('excelexport.ashx')? – Joe Carr Feb 04 '13 at 17:27

1 Answers1

1

Ok so this turned out to be a schoolboy error......

I had done a simply copy paste to create the new handler and edited all the code behind functionality. What I forgot however was that there is also a mark-up page associated with .ashx file which also needed editing.

<%@ WebHandler Language="C#" CodeBehind="ProductExportExcel.ashx.cs" Class="ITG.MediaCentre.Crew.WebApplication.Handlers.ExportExcel" %>

What you will notice is that the Class portion is pointing to the incorrect class hence the wrong code is executed even though the URL is pointing to the correct location.

Hope this helps somebody out in the future.

Cheers

Morn
  • 191
  • 1
  • 4
  • 14