473,468 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Generic handler - problem

6 New Member
Hello, i have the following problem with my Generic handler - it just doesn't execute! In my handler i have to get an icon from a file, save it to a bmp file and then write the icon to the response. Here is my code for the handler

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "image/png";

try
{
int id = int.Parse(context.Request.QueryString["id"]);
Bitmap image = Icon.ExtractAssociatedIcon(_Default.Files[id].FullName).ToBitmap();
MemoryStream stream = new MemoryStream();
image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.WriteTo(context.Response.OutputStream);
stream.Flush();
context.Response.Flush();
}
catch (UnauthorizedAccessException ex)
{
context.Response.Write(ex.Message);
}
catch (FileNotFoundException ex)
{
context.Response.Write(ex.Message);
}
}

And here is how i call it -

for (int i = 0; i != Files.Length; i++)
{
node = new TreeNode(Files[i].Name);
node.ImageUrl = "/HandlerImages.ashx?id="+ i.ToString();
//node.ImageUrl = "Images.aspx?id=" + i.ToString();
treeViewFiles.Nodes.Add(node);
}

When i start the application i can see that no icons had been drowned to the response. When trying to debug the same results occur. I have looked in some articles about handlers and everything seems to be ok, but it just dont work! When i try the same thing with an aspx page instead of handler it works... but this is not the way that images are supposed to be handled in asp. Help :(
Oct 20 '08 #1
1 1147
eeasss
6 New Member
The problem is fixed, in my desparation i deleted the hadnler and then recreated it... and jezuz it worked. Hi Aspx bugs.
Oct 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Csaba Gabor | last post by:
The usual example shown for trapping for failure of COM instantiation (Windows systems) is something like (see for example http://at2.php.net/manual/en/class.com.php): $word = new...
2
by: Jon Davis | last post by:
The garbage handler in the .NET framework is handy. When objects fall out of scope, they are automatically destroyed, and the programmer doesn't have to worry about deallocating the memory space...
5
by: Richard Brown | last post by:
Ok, I've been looking through the .NET SDK docs and stuff. I'm wondering if you can provide a control extender that does generic validation or functionality just by dropping it on the form. For...
8
by: Woody Splawn | last post by:
Could someone give me a suggestion for writing generic code in a validating event for trimming the value of a textbox entry? I thought something like the following might work but it does not. ...
2
by: mark | last post by:
Is there a means of raising an event when ANY button on a windows application form is clicked wherein the actual button clicked can be determined in the generic click events code (eg by way of...
6
by: David Veeneman | last post by:
I have several events that pass a value in their event args. One event passes an int, another a string, another a DateTime, and so on. Rather than creating a separate set of event args for each...
0
by: Mikkel Blanné | last post by:
I haven't been able to find any references to using this combination of technologies (remoting + generic methods + method overloading). I don't think the problem has to do with C#, but I couldn't...
10
by: phancey | last post by:
I'm quite new to generics. I have 2 generic classes: MyClass<Tand MyOtherClass<T>. MyClass<Thas 2 public Add methods Add(MyOtherClass<T>); Add(MyOtherClass<Wrapper<T>>); (Wrapper<Tis another...
1
by: eeasss | last post by:
Hello, i have the following problem with my Generic handler - it just doesn't execute! In my handler i have to get an icon from a file, save it to a bmp file and then write the icon to the response....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.