tags:

views:

539

answers:

3

I know this is working because I'm getting data populated in a jQuery plug-in once it parses the JSON response. And I've called this so many times before in the past just to check out the returned JSON in the browser. But lately for whatever reason, and after I've stepped through with the debugger to find that the code in my .ashx is working just fine, I get a download prompt returned prompting me to download the .ashx file instead of JSON

http://localhost:59396/xxx/xxxHandler.ashx?action=getproducts&showprodname=true&showprodprice=true&ids=5410,8362,6638,6758,7795

A: 

Have you observed your network traffic (e.g. www.fiddler2.com)? What Content-Type is getting returned?

Have you saved the file to see what's actually in it?

If you're getting source code, that means that the HTTPHandler isn't actually running to actually execute the ASP.NET source.

EricLaw -MSFT-
The source is being executed, I stepped through it.
CoffeeAddict
Whether or not IE is going to offer to save "application/json" or try to render it as text depends on what you have in your registry for that MIME type.
EricLaw -MSFT-
A: 

Have you hosted the web page under IIS? It could be because .ashx file extension is not registered with IIS. Check for .ashx extension under IIS file mappings in that case.

Prashanth
Then why was it working for the past week and now decides not to?
CoffeeAddict
Possible re registration of file mappings, something went wrong in aspnet_regiis, could be many things. I am not saying that the problem is because of that, but could be.
Prashanth
A: 

Confirm you have the proper content type as EricLaw suggests, but if you are trying to browse directly to the JSON, it is working as designed. Request the url from javascript and see if you get the expected data response. The browser sees the file as a ASHX file, which is registered to visual studio, but it is actually just a text file you should be able to read in anything if it is in fact json.

Wyatt Barnett
I've been pasting this in the browser for a week straight. Never have I gotten a prompt to download the .ashx instead of the actual JSON. I have always gotten JSON back and I stepped through it and the string I am returning in my .ashx code has valid JSON being sent to the context writer
CoffeeAddict
I was able to just run this and it outputted the JSON right to the browser all along in the past week!
CoffeeAddict
Well, then perhaps you might want to see what the ASHX file contains--sounds the output might not be json anymore. Like said handler is throwing an exception . . .
Wyatt Barnett