generic-handler

How do I inject into some generic asp.net http handler using Ninject?

北慕城南 提交于 2020-01-02 02:53:06
问题 I'm a newbie using Ninject and I can't figure out how to inject into my generic http handler. I have a MVC3 project and I'm injecting my services into controllers with no problem at all. This is what I got in my Ninject App_start class for registering services: private static void RegisterServices(IKernel kernel) { kernel.Bind<NLSubscriber.Core.Service.Repository.INLUserRepository>().To<NLSubscriber.Core.Service.Repository.EFDAL.EFNLUserRepository>().InRequestScope(); kernel.Bind<Neticon.Mvc

File Upload with jQuery AJAX and Handler (ashx) not working

时光怂恿深爱的人放手 提交于 2019-12-30 03:37:06
问题 I'm trying to upload an image file with jQuery AJAX and a generic handler. But it seems that the file isn't being passed to the handler. After submit context.Request.Files[0]; is always null :-/ What am i doing wrong? HTML: <form id="form1" runat="server" method="post" enctype="multipart/form-data"> <input name="file" id="file" type="file" /> <input id="save" name="submit" value="Submit" type="submit" /> </form> JS: $().ready(function () { $('#file').change(function () { sendFile(this.files[0

Retrieve image of image control as byte array which is set using generichandler(.ashx)?

你。 提交于 2019-12-25 02:18:57
问题 currently I'm using GenericHandler(.ashx) for displaying an image in image control. See below code: [1] .ASPX <asp:Image ID="Image1" runat="server" Width="350px" Height="415px" /> [2] .cs(codebehind) Image1.ImageUrl = string.Format("GridviewImage.ashx?ItemID={0}", itemID); Now I need to get image of Image1 as a byte array ( byte[] ). Is it possible? 回答1: If you have several images being streamed to the page, set the IsReusable to true. Use a DataReader for streaming the image back, not a

Retrieve image of image control as byte array which is set using generichandler(.ashx)?

守給你的承諾、 提交于 2019-12-25 02:18:32
问题 currently I'm using GenericHandler(.ashx) for displaying an image in image control. See below code: [1] .ASPX <asp:Image ID="Image1" runat="server" Width="350px" Height="415px" /> [2] .cs(codebehind) Image1.ImageUrl = string.Format("GridviewImage.ashx?ItemID={0}", itemID); Now I need to get image of Image1 as a byte array ( byte[] ). Is it possible? 回答1: If you have several images being streamed to the page, set the IsReusable to true. Use a DataReader for streaming the image back, not a

Restrict direct file access of our attachment folder

倖福魔咒の 提交于 2019-12-25 00:59:11
问题 We have this website where we also have a visa application module. The visa application module requires the user to create an account. Whenever the user uploads attachments it is saved in a specific folder inside attachments. This specific folder corresponds to a uniquely generated numbers that is assigned to each user. Now what I need is if the user is not login they should not be able to access the files inside the attachment folders. How can I achieve that using http handler? I have this

How to open files stored as bytes in database with http handler?

烈酒焚心 提交于 2019-12-13 17:40:28
问题 I have my files stored as bytes in my database. How to open files like this with its application (like microsoft office, acrobat reader ,...etc) or download it. I want to do this with generic handler : public class Attachement : IHttpHandler, System.Web.SessionState.IRequiresSessionState { public void ProcessRequest(HttpContext context) { try { byte[] Attachement = (byte[])AttachementDAL.ReadAttachement(int.Parse(context.Session["attch_serial"].ToString())).Rows[0]["attach_content"]; } catch

Create json using JavaScriptSerializer

陌路散爱 提交于 2019-12-13 08:26:06
问题 I have following code in Generic Handler of Asp.net: var students= Student.GetStudents(); var result = new { Data = students.Select(s => new []{s.subjects}) }; var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); var json = serializer.Serialize(result); context.Response.ContentType = "application/json"; context.Response.Write(json); Applied on the Class Student : public class Student { public List<String> subjects{get; set;} Student() { subjects= new List<string>(); }

MVC3 generic handler (.ashx) for Images resizing (Need clean URL)

邮差的信 提交于 2019-12-12 17:29:57
问题 I have a generic handler (.ashx) in asp.net mvc3 web application. I use it to resize and cache images. but my Url is not clean (http://www.example.com/Thumb.ashx?img=someimage.jpg) I want to make it clean like http://www.example.com/Thumb/someimage.jpg how can I do it? Can I maproute in global.asax, it yes then how? or should I use IIS 7 URL rewrite? I appreciate any help, Thanks 回答1: After few hours of research I have done it using class (RouteHandler.cs) http handler but not with .ashx

Unit Testing ASP.NET Generic Handlers without using HttpWebRequest

五迷三道 提交于 2019-12-12 05:38:23
问题 I need to create Unit test cases for my ASP.NET generic Handler. My Handler code is as below: public class MyHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("Hello World"); var data = context.Request.InputStream; //Here logic read the context.Request.InputStream //All the data will be posted to this Stream //Calling of business logic layer Methods } public bool IsReusable { get { return false; } } }

How can I generate a thumbnail from an image in server folder?

给你一囗甜甜゛ 提交于 2019-12-12 01:33:39
问题 I've been trying to figure this out but I'm not getting anywhere. What I'm trying to do is this: I have a aspx page where you can upload images (they are stored in a folder on the server), on one page you can see all the uploaded images and it generates links (a tags) with a reference to these images, but until now it loaded the full images as a "thumbnail" and they are far too large in size (1920x1200px), So I replaced the image src with a generic handler, which should get the image from the