FAQ Database Discussion Community


HttpHandler does not send response after catching SqlException?

asp.net,ashx
This HttpHandler does not send a response if con.Open() throws an exception, for example if faultyConnectionString has an invalid database name. Why? public void ProcessRequest(HttpContext context) { int status = 400; string message = "Test error!"; string faultyConnectionString = "Data Source=LOCALHOST\\SQLEXPRESS;Initial Catalog=XXX;User ID=XXX;Password=XXX"; try { using (SqlConnection con = new...

Display base64 image using generic handler(ashx)

c#,asp.net-mvc,base64,ashx
I am trying to display base64 using generic handler but not getting success. Here is my code of generic handler: public class UserProfilePhoto : IHttpHandler, IReadOnlySessionState { public void ProcessRequest(HttpContext context) { try { if (UserSession.Get().UserPhoto == null) { context.Response.ContentType = "image/png"; context.Response.WriteFile("~/assets/img/avatar.png"); } else { context.Response.ContentType = UserSession.Get().UserPhoto.Substring(0, UserSession.Get().UserPhoto.IndexOf(","));...

Is it a bad idea to use ASHX for an entire website? [closed]

c#,asp.net,ashx
I made multiple website in the past using HTML or Perl. I am now looking to use ASP.Net since it allow me to use a language that I am more comfortable with (C#). I made some experiments with the aspx pages and it seems like they always add viewstates and...

How do I instantiate the Profile from an ashx file?

asp.net,httphandler,ashx,profile-provider
I recently switched some AJAX queries to use ashx files instead of aspx, having discovered that Response.End is no longer in vogue. In the case I'm looking at now, the submission of a purchase order is handled by the ashx. The user clicks the Submit button on the PO and...

uploading file using ashx filehandler and ajax always return error

jquery,.net,file-upload,webforms,ashx
I am using jquery-file-upload from blueimp (https://blueimp.github.io/jQuery-File-Upload/). I have FileHandler.ashx for file uploads. I am not able to return correct response from file handler. On javascript side, it always receives error. Please, guide me. // File handler (FileHandler.ashx) public void ProcessRequest(HttpContext context) { string fname = String.Empty; if (context.Request.Files.Count >...

How to Use web Handlers for PDF creation?

c#,asp.net,web-applications,ashx,aspx-user-control
I have pretty less knowledge in web handlers. all i know is web handlers are used for creating some dynamic file creation purpose. and also i know how to add the Web handlers. But, i need to use web handlers in my Asp.Net project for PDF creation purpose. Anyone have...

read image using ashx doesn't work in asp.net

c#,asp.net,image,ashx
I am trying to use ashx to load an image from database . when i use this code the image is loaded successfully <% <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Id", "~/Handler/CategoryHandler.ashx?catId={0}") %>' /> But when i use this code <% foreach (ProductCategories VARIABLE in categoriesList) { Response.Write("<div class='wrapper-box'>" + "<a href='product/product.aspx'>"...

Webconfig error ASPX and ASHX

asp.net,vb.net,web-config,ashx
I have been put in charge of maintaining an old legacy website(hasn't been touched in maybe 4-5 years) using ASPX and ASHX. The website was working decently on server 2003, but the web host forced us to move to 2008. Upon moving to 2008 we received this error Config Error...