Display image from database in ASP.net with C#

try using a handler file (.ashx) put the code form your page_load in that lie so public void ProcessRequest (HttpContext context) { //Get the picture id by url //Query here byte[] picture = queryoutput; Response.ContentType = “images/jpeg”; Response.BinaryWrite(picture); } public bool IsReusable { get { return false; } } then call the handler file and … Read more

how to remove ‘name’ attribute from server controls?

create a Filter (class that inherits from Stream), assign it to your HttpContext.Response.Filter attribute, and in it you would overwrite the Write method, to remove all the name-tags from the generated html 🙂 See this page for more information http://msdn.microsoft.com/en-us/library/system.web.httpresponse.filter.aspx Update Looking at the sourcecode for TextBox it reveals that Name is actually added to … Read more

How do modern implementations of Comet/Reverse AJAX work? Any stable C# WCF or ASP.NET implementations?

I have hear about, WebSync and PokeIn, both are paid implementations, I have used PokeIn and its pretty straight forward. If you are looking forward to code your own COMET implementation, I just can say that its a complex task, because you need to modify the natural behaviour if IIS. Its a hacky way to … Read more

file download by calling .ashx page

Your file is downloading, but you get it on javascript, on the data parameter of your call because you call it with Ajax. You use a handler – so ajax not needed here, and the most easy thing to do using javascript is that: window.location = “https://stackoverflow.com/questions/12087040/FileDownload.ashx?parametres=22″; or with a simple link as <a target=”_blank” … Read more

Where does ASP.NET virtual path resolve the tilde “~”?

It gets it from here: VirtualPathUtility.ToAbsolute(contentPath, httpContext.Request.ApplicationPath); Here is the reflector output for PathHelpers class in System.Web.Mvc DLL: private static string GenerateClientUrlInternal(HttpContextBase httpContext, string contentPath) { if (string.IsNullOrEmpty(contentPath)) { return contentPath; } if (contentPath[0] == ‘~’) { string virtualPath = VirtualPathUtility.ToAbsolute(contentPath, httpContext.Request.ApplicationPath); string str2 = httpContext.Response.ApplyAppPathModifier(virtualPath); return GenerateClientUrlInternal(httpContext, str2); } NameValueCollection serverVariables = httpContext.Request.ServerVariables; if … Read more

ASP.net session request queuing

This behaviour is by design; no concurrent access to the session state is allowed. Requests with same SessionID will be locked exclusively to prevent potential corruption of its state. To get around this you can disable session state in your page directive. <%@ Page EnableSessionState=”false” %> Read “Concurrent Requests and Session State” here http://msdn.microsoft.com/en-us/library/ms178581.aspx for … Read more

Force CamelCase on ASP.NET WebAPI Per Controller

Thanks to @KiranChalla I was able to achieve this easier than I thought. Here is the pretty simple class I created: using System; using System.Linq; using System.Web.Http.Controllers; using System.Net.Http.Formatting; using Newtonsoft.Json.Serialization; public class CamelCaseControllerConfigAttribute : Attribute, IControllerConfiguration { public void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor) { var formatter = controllerSettings.Formatters.OfType<JsonMediaTypeFormatter>().Single(); controllerSettings.Formatters.Remove(formatter); formatter = new JsonMediaTypeFormatter { … Read more