Change language of error messages in ASP.NET

In web.config add: <system.web> <globalization uiCulture=”en-US” /> </system.web> or whatever language you prefer (note: uiCulture=”en-US” not culture=”en-US”). Also you should check that your app is not changing the uiCulture, for example to a user-specific uiCulture in global.asax. If the error occurs before or during processing the web.config file, this will of course make no difference. … Read more

Singleton Per Call Context (Web Request) in Unity

Neat solution, but each instance of LifetimeManager should use a unique key rather than a constant: private string _key = string.Format(“PerCallContextLifeTimeManager_{0}”, Guid.NewGuid()); Otherwise if you have more than one object registered with PerCallContextLifeTimeManager, they’re sharing the same key to access CallContext, and you won’t get your expected object back. Also worth implementing RemoveValue to ensure … Read more

Is there a recommended way to return an image using ASP.NET Web API

You shouldn’t return a System.Drawing.Image, unless you also add a formatter which knows how to convert that into the appropriate bytes doesn’t serialize itself as the image bytes as you’d expect. One possible solution is to return an HttpResponseMessage with the image stored in its content (as shown below). Remember that if you want the … Read more

call aspx page to return an image randomly slow

Because you use .aspx page (and not handler), and because the images loaded by browser not one by one, but many together, I suspect that you felt on the session lock of the page and that’s why this delay. Try to set EnableSessionState=”false” on the page. eg: <%@ Page language=”c#” Codebehind=”WebForm1.aspx.cs” AutoEventWireup=”false” Inherits=”WebApplication1.WebForm1″ EnableSessionState=”false” %> … Read more

ASP.NET: Highlight menu item of current page

There’s a StaticSelectedStyle property that you can use inside your menu. <asp:menu […]> <staticselectedstyle backcolor=”LightBlue” borderstyle=”Solid” bordercolor=”Black” borderwidth=”1″/> […] </asp:menu> See here for more info. Also, if there’s a class applied to the selected item (which i’m not sure if there is but it would be handy) you can simply hook into that with your … Read more

File uploading in AJAX updatepanel without full postback

For solve this problem, Please see the following step. Add ajax-upload to your detail view. iframe-based uploader like Resource#1. Silverlight-based & Flash-based uploader. I like this technique because it doesn’t require any server-side script for display current upload status. But in HTML5, you can create this without using any web browser plug-in. Commercial uploader like … Read more

Session_End does not fire?

You may set some Session data in Session_Start. Without this, Session_End will not be fired. see this Also another very important thing to note here is that if you do not save anything in the session the Session_End event will not fire. There must be something saved in the session atleast once for the Session_End … Read more