My web site has a handler (FileDownload.ashx) that deals with all file download requests. I've recently migrated my site to ASP.Net 4.0, and it now uses routing extensively. Everything works fine when dealing with page requests (aspx), but it's not working with my handler - I encounter the following error:
Type '<snip>.Handlers.FileDownload' does not inherit from 'System.Web.UI.Page'.
This makes sense, as routing is only implemented in the page. So, my question is, what steps do I need to take to be able to use routing and my ASHX together? I want to be able to extract RouteData.Values from the url.
Although I'm not using routing in an MVC application, this post seems to fit best here :)
I'm trying to access the datatokens that I've passed with the MapPageRoute-method and in a simple Webforms page it works, but in Application_AuthorizeRequest it seems like it's not populated yet.. DataTokens.Count returns 0 although I have passed one item
Is there an alternate way to access the DataTokens? The routing has initialized (it seems), because there's a major difference between url's that is mapped and one that's not..
From the regular Webforms page I'm using Page.RouteData.DataTokens["PagesID"] and in the global.asax file I'm using Request.RequestContext.RouteData.DataTokens["PagesID"]
Is it possible, and if so how do you access the webpage from the webhandlers?
Basically, when i button is clicked i kick off some JavaScript, which then kicks off a C# webhandler which return data from the server. What i would like to do then is rather than feed it back to the JavaScript, id like to add a GridView directly to the webpage from the webhandler.
Equally, within the handler it would be incredible useful to be able to read values of dropdowns etc from the webpage.
I have several routes defined in my Global.asax; now, when I'm on a page I need to figure out what is the route name of the current route, because route name drives my site menu. I can't find a way to get current route name.
Actually the handler never gets called. I already searched the forums and tried some tips and hints. But nothing of that worked. Try to call the url via[URL]
There is an ashx file containing "ProcessRequest(HttpContext context)" method which gets triggered automatically. When and how does it get fired?Another question, How can I get the current QueryString when I am inside this file? When I type "context.Request.QueryString" it says it's null or empty although the address have arguments.
I've got a simple ASHX handler that returns an dynamically generated image; the image is generated from a custom created class, and an object belonging to this class is passed to the handler using Session (I'd rather avoid using QueryString).The handler is used as the URL of an image on a ASP form which is very simple: a drop down list, a button and an image. Basically, depending on what the user selects from the list, the appropriate image will be generated once the button is pressed.
At the start the actual image has it's Visible property set to false; I don't want the handler to display anything before the data is all there.Once the button is pressed, the required Session parameter is added containing the necessary object, and the page is refreshed using Server.Transfer. When the Page_load method detects that the Session parameter has been correctly set, it sets the Visible parameter on the image to true.After that the handler fires up and generates the image.
So far so good... However, if the user now picks something different from the list and presses the button, despite the correct object being passed in the Session, the image won't be updated. In fact, the handler won't even fire up (if I put a breakpoint in there). I need to close the browser window and reopen it for it to work.Any ideas what could be the cause of such behaviour?I suspect the answer is very simple, and I just don't know something fundamental about ASP (or handlers)...
In my web application I use an ashx file to write a file to the browser. I've noticed that there's no compression over the .ashx file, but only over my .aspx files.
Is it possible to compress .ashx? And if it is possible, how?
Currently I use global.asax to handle the compression:
As you can see only files which inherit from 'Page' are compressed, and my ashx file is not of type Page. So I added a condition and now it works just fine:
if (!(app.Context.CurrentHandler is Page || app.Context.CurrentHandler.GetType().Name == "SyncSessionlessHandler" || app.Context.CurrentHandler is ViewMht // This is the type I had to add ) || app.Request["HTTP_X_MICROSOFTAJAX"] != null) return;
I have created webpage and I am calling it from Jquery function. Technically I am {info} is image button and I am replacing with it with aspx
.replace("${info}","/_layouts/webpage.aspx");
The web page is opening in new browser window. Is there any way that I could make it as pop up whereever I can place in the page. That is get rid off the toolbar address bar. It should look like a pop up.
I am using ashx to serve images from a database, is there anyway to have a user click on a link that allows them to download the file on the computer. (IE it shows the Save Dialog) Like you download a file.
I've been trying to use the jQuery plugin Colorbox to display images I have in my DB through an ashx file. Unfortunately it just spits a bunch of gibberish at the top of the page and no image. Can this be done? Here is what I have so far:
$(document).ready ( function () { $("a[rel='cbImg']").colorbox(); } ); ... <a rel="cbImg" href="HuntImage.ashx?id=15">Click to see image</a>
I have ASP.NET page with an iframe on it for displaying some pdf reports on this page. When user select the report type from dropdown, I add the needed for report data into the ASP.NET Session and change the attribute "src" of the iframe to .ashx module address which generates the .pdf report.But if Adobe glug-in for viewing .pdf files in browser is not installed, browser proposes to save report file and name of the proposed file is "HandlerName.ashx".But I want to make the browser proposed to save the file with the name "Report.pdf".