473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem compiling Handler.ashx

9
Can somebody help please. I'm trying to compile Handler (code is below), but I'm getting error message :
ImageHandle.ashx<1,1>:error Cs0116: A namespace does not directly contain members such as fields or methods.
I can't figure out what the problem is.
Thanks!

Expand|Select|Wrap|Line Numbers
  1. <%@ WebHandler Language="C#" Class="ImageHandler" %>
  2.  
  3. using System;
  4. using System.Web;
  5. using System.Web.Configuration;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8.  
  9. public class ImageHandler : IHttpHandler 
  10. {
  11.  
  12.     public void ProcessRequest (HttpContext context) 
  13.     {
  14.         string connString = WebConfigurationManager.ConnectionStrings["AdWorks"].ConnectionString;
  15.         string photoId = context.Request.QueryString["PhotoId"];
  16.         SqlConnection conn = new SqlConnection(connString);
  17.         string sql = "SELECT ThumbnailPhoto FROM Production.ProductPhoto WHERE ProductPhotoID = @ProductPhotoID";
  18.         SqlCommand command = new SqlCommand(sql, conn);
  19.         command.Parameters.AddWithValue("@ProductPhotoID", photoId);
  20.         try
  21.         {
  22.             conn.Open();
  23.             SqlDataReader reader = command.ExecuteReader(CommandBehavior.SequentialAccess);
  24.             if (reader.Read())
  25.             {
  26.                 int bufferSize = 100;
  27.                 byte[] bytes = new byte[bufferSize];
  28.                 long bytesRead;
  29.                 long readFrom = 0;
  30.                 do
  31.                 {
  32.                     bytesRead = reader.GetBytes(0, readFrom, bytes, 0, bufferSize);
  33.                     context.Response.BinaryWrite(bytes);
  34.                     readFrom += bufferSize;
  35.                 }
  36.                 while (bytesRead == bufferSize);
  37.             }
  38.             reader.Close();
  39.         }
  40.         finally
  41.         {
  42.             conn.Close();
  43.         }
  44.     }
  45.  
  46.     public bool IsReusable 
  47.     {
  48.         get 
  49.         {
  50.             return false;
  51.         }
  52.     }
  53.  
  54. }
  55.  
May 1 '08 #1
4 3860
mil111
9
I still haven't found the solution. Does somebody know what the problem is, please?
Thanks!!!
May 3 '08 #2
kenobewan
4,871 Expert 4TB
Here is a post that may help:
Command Line Compiler, CS0116: A namespace does not directly contain members such as fields or methods

or try:
Compiler Error CS0116

I still haven't found the solution. Does somebody know what the problem is, please?
Thanks!!!
May 3 '08 #3
mil111
9
Thanks,
I'll try this, maybe it will help.
May 5 '08 #4
In Visual Studio right click and select properties on the codebehind file "myhandler.ashx.cs" onn the Build Action select Compile. Then rebuild solution and run all should be tickety-boo!
Nov 13 '10 #5

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

Similar topics

0
by: Luca | last post by:
Hi all. I've a problem compiling PHP (both 4.3.6 and 5 rc2) with ldap support (--with-ldap). "configure" doesn't return any error, but when I launch "make" it returns: grep:...
0
by: Nikola Milutinovic | last post by:
Hi all. I'm not subscribed to the list, so all replies to me mail directly. I ran into a small problem, for which we have found a workaround. I was compiling PostgreSQL v7.4.1 and it's...
2
by: Joel | last post by:
I am having some problems compiling my code on Mandrake 10 with g++ (GCC 3.3.2). The problem seems to be in that I try to define a functor that compares two pointer objects, and use that functor to...
0
by: JJ | last post by:
I am trying to use .ashx files to handle dynamic image requests. The aspx page needs to pass the data to the ashx file. It was decided to not use the query string. Instead we hoped we could use the...
0
by: Usman | last post by:
Hi there I'm having problem compiling my code. I have a library along with its header file that I've used in my Com project. On compilation I get this linking error. Does anyone have any idea...
0
by: erkidevries | last post by:
Problem compiling Tkinter program with bmp images (using py2exe) I have a Tkinter gui program that uses bmp as backgrounds. The program itself works when I run from the source. I placed the...
3
by: JJ | last post by:
I am using a handler (processImage.ashx) to display an image. The image is displayed according to parameters passed in the querystring. The handerl is called via some clientside javascript. I...
2
by: eliben | last post by:
On Jun 27, 3:10 pm, eliben <eli...@gmail.comwrote: Problem solved: http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/
8
by: wingleader | last post by:
Hi everyone! I've got such a problem, that I'm using Kdevelop 3. Kdevelop offer only cmake for compiling with shared library support. So it uses CMakeLists.txt as config file for that#add...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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,...

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.