httphandler

Can't PUT to my IHttpHandler, GET works fine

為{幸葍}努か 提交于 2019-12-23 02:01:31
问题 I'm in the process of writing an IHttpHandler. My environment is Windows 7 Enterprise, IIS 7 (it appears). My handler is running as an application under the default app pool which is running in integrated mode. Currently my handler's ProcessRequest() method only does the following (just testing at this point): public void ProcessRequest(HttpContext context) { context.Response.StatusCode = 200; context.Response.ContentType = "text/html"; context.Response.Output.Write("file uploaded."); } I add

Deadlock reading async response content from async DelegatingHandler in webapi

百般思念 提交于 2019-12-22 13:59:11
问题 Problem I'm using a DelegatingHandler in WebAPI to read the response Content and audit it to the database. When the code gets to .ReadAsStringAsync() it appears to lock and prevent other requests from completing. I only know this, because when I remove the offending line, it works perfectly. public static void Register(HttpConfiguration config) { config.MessageHandlers.Add(new ResourceAuditHandler()); } public class ResourceAuditHandler : DelegatingHandler { protected override async Task

ASP.net HttpHandler long running ProcessRequest doesn't end on App recycle

妖精的绣舞 提交于 2019-12-22 10:35:27
问题 I'm trying to implement an HttpStreaming comet push server in ASP.net. I am implementing an IHttpAsyncHandler that holds onto an http request and periodically sends messages down to the connected client. The connection with the client can be held open for a very long time (lets say 30 minutes). The issue that I am having is that since I don't end the request for a very long time, the handler technical is still running. So when the app pool recycles or ends, my asp.net application doesn't end

IIS7 file mappings - .asax, .ashx, .asap

假如想象 提交于 2019-12-22 09:16:18
问题 IIS enables us to also configure Asp.Net file mappings. Thus besides aspx, IIS also invokes Asp.Net runtime, when requests have the following file extensions: a) .ascx --> .asmx extension is used to request user controls. Since user controls can’t be accessed directly, how and why would anyone send a request to a user control? b) .ashx --> this extension is used for HTTP handlers. • But why would you want to request an .ashx page directly instead of registering this handler inside

asp.net custom HttpHandler and URL routing

别来无恙 提交于 2019-12-22 05:41:55
问题 I want handle the requests to my application "http://example.com/whateverpath" by a custom HttpHandler but the return things depending of the value of "whateverpath". So users accessing "http://example.com/path1" will get different response than users accessing "http://example.com/path2", but both request must be handled in the same HttpHandler. The idea is find "whateverpath" in a database and depending of the result, return the response content. I hear about URL routing and I already have a

“Content-encoding” header disappears from HttpHandler response if an exception occurs

一曲冷凌霜 提交于 2019-12-22 05:27:06
问题 I have a custom HttpHandler in which I manually enable output compression, like so: context.Response.AppendHeader("Content-encoding", "gzip"); context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress); This works nicely for most requests, but when an exception is encountered the "Content-encoding" header disappears from the response, while the compression filter remains in place. The result is that the error page is gzip compressed, but the browser receives

Server.Transfer to an HttpHandler

好久不见. 提交于 2019-12-22 05:17:46
问题 I have an IHttpHandler with the following ProcessRequest method: public void ProcessRequest(HttpContext context) { int id = Convert.ToInt32(context.Request.QueryString["id"] + 151); var xml = XDocument.Parse("<xml><cartid>" + id + "</cartid></xml>"); context.Response.Write(xml); } Which I'm trying to use from an aspx page as follows: protected void Page_Load(object sender, EventArgs e) { order o = new order(); Server.Transfer(o, false); } I get an HttpException: Error executing child request

HttpHandler fire only if file doesn't exist

烂漫一生 提交于 2019-12-21 01:59:06
问题 I'm trying to create a HTTP handler to handle all requests to a folder but I only want it to fire if the files requested don't exist (EG: Request comes in for file X, if X exists I'd like to serve the file, otherwise the handler should deal with it). The files will only be static content, not scripts themselves, which I assume makes it a bit easier but I can't seem to find anything that will do the trick... Anyone have any ideas? I assume it can be done since the IIS7 rewrite module can

How to use Generic Handlers (ASHX) in ASP.NET MVC?

谁都会走 提交于 2019-12-20 08:43:32
问题 I need a image generator in my ASP.NET MVC application, but I don't know if it is possible to use ASHX in ASP.NET MVC. If there is an class similar to IHttpHandler that inherits IViewDataContainer, then I could use ViewData.Model on my ASHX. I read a blog post about it but it seem outdated from the info I got in the ASP.NET forum Any ideas? 回答1: You should just be able to return the image from the action? See here for more. And yes, you can use ashx alongside MVC (by telling it to ignore the

Setting Autorization rules for ashx handler in ASP.NET MVC 3 application

末鹿安然 提交于 2019-12-20 05:39:32
问题 I am implementing a javascript file upload functionality in my MVC 3 application and therefore I need to use Http Handler (.ashx) to allow large file upload. Now I need to somehow forbid unauthenticated users to call handler's methods. If I had a controller, I would simply apply [Authorize] attibute to it. But does the attribute work when applied to an Http Handler's method? IF not, how can I allow only people that have a current session cookie to make calls to Http Handler? 回答1: You could