469,268 Members | 1,013 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,268 developers. It's quick & easy.

badly stuck creating HTTPHandler

Hi everybody,

I have got a serious problem building an HTTPHandler in codebehind style.
I made the following steps:
Create an ASP .net Website project
Add a generic handler.
Rewrite this "Hello World" item into codebehind style so that the .ashx file
has the only line:
<%@ WebHandler Language="C#" Class="handlerpur"
CodeBehind="handlerpur.ashx.cs" %>

The codebehind file has the rest of the former content of the ashx file:

using System;
using System.Web;

namespace MyNamespace {
public class handlerpur : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}
}

Trying to build that I get the error:
Could not create type 'myNameSpace.handlerpur' pointing at the first line of
the ashx file.
I checked permissions, the virtual directory on the iis (it has got an app
name), added things to the web.config, checked the framework version on the
iis.
Am I missing something? I do not have a bin directory in my project and
nothing gets compiled.
I am running WinXp SP2, iis 5.1, ASP.net 2.0.50727.

Any help is greatly appreciated

Thanks

Ivonne.
Jan 25 '06 #1
3 7162
Due to the new way ASP.NET projects are compiled, you have one of two
choices here:

First, you could combine everything into your ASHX file (see below):

<%@ WebHandler Language="C#" Class="MyNamespace.handlerpur" %>

using System;
using System.Web;

namespace MyNamespace
{
public class handlerpur : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get {return false;}
}
}
}

Or you could put the handlerpur.cs file in your App_Code directory so that
it's compiled into the web project DLL and then your ASHX file would only
have the webhandler directive:

<%@ WebHandler Language="C#" Class="MyNamespace.handlerpur" %>

I don't believe that the WebHandler directive allows for 'code behind'
files like a page does.

HTH,

Matt Dinovo

"Ivonne Riedel" <iv***********@t-online.de> wrote in message
news:dr*************@news.t-online.com...
Hi everybody,

I have got a serious problem building an HTTPHandler in codebehind style.
I made the following steps:
Create an ASP .net Website project
Add a generic handler.
Rewrite this "Hello World" item into codebehind style so that the .ashx
file has the only line:
<%@ WebHandler Language="C#" Class="handlerpur"
CodeBehind="handlerpur.ashx.cs" %>

The codebehind file has the rest of the former content of the ashx file:

using System;
using System.Web;

namespace MyNamespace {
public class handlerpur : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}
}

Trying to build that I get the error:
Could not create type 'myNameSpace.handlerpur' pointing at the first line
of the ashx file.
I checked permissions, the virtual directory on the iis (it has got an app
name), added things to the web.config, checked the framework version on
the iis.
Am I missing something? I do not have a bin directory in my project and
nothing gets compiled.
I am running WinXp SP2, iis 5.1, ASP.net 2.0.50727.

Any help is greatly appreciated

Thanks

Ivonne.

Jan 25 '06 #2
Hi Matt,

I read in an article that it should be possible (various ones to be
precise).
E.g. http://cs.swan.ac.uk/~csneal/Reliabl...ceExample.html
I will try the second option you gave me as I needed compiled code for speed
matters and to pass parameters.
Thanks so far

Ivonne.

"Matt Dinovo" <matt_at_swiftus_dot_com> schrieb im Newsbeitrag
news:eH**************@TK2MSFTNGP10.phx.gbl...
Due to the new way ASP.NET projects are compiled, you have one of two
choices here:

First, you could combine everything into your ASHX file (see below):

<%@ WebHandler Language="C#" Class="MyNamespace.handlerpur" %>

using System;
using System.Web;

namespace MyNamespace
{
public class handlerpur : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get {return false;}
}
}
}

Or you could put the handlerpur.cs file in your App_Code directory so that
it's compiled into the web project DLL and then your ASHX file would only
have the webhandler directive:

<%@ WebHandler Language="C#" Class="MyNamespace.handlerpur" %>

I don't believe that the WebHandler directive allows for 'code behind'
files like a page does.

HTH,

Matt Dinovo

"Ivonne Riedel" <iv***********@t-online.de> wrote in message
news:dr*************@news.t-online.com...
Hi everybody,

I have got a serious problem building an HTTPHandler in codebehind style.
I made the following steps:
Create an ASP .net Website project
Add a generic handler.
Rewrite this "Hello World" item into codebehind style so that the .ashx
file has the only line:
<%@ WebHandler Language="C#" Class="handlerpur"
CodeBehind="handlerpur.ashx.cs" %>

The codebehind file has the rest of the former content of the ashx file:

using System;
using System.Web;

namespace MyNamespace {
public class handlerpur : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}
}

Trying to build that I get the error:
Could not create type 'myNameSpace.handlerpur' pointing at the first line
of the ashx file.
I checked permissions, the virtual directory on the iis (it has got an
app name), added things to the web.config, checked the framework version
on the iis.
Am I missing something? I do not have a bin directory in my project and
nothing gets compiled.
I am running WinXp SP2, iis 5.1, ASP.net 2.0.50727.

Any help is greatly appreciated

Thanks

Ivonne.


Jan 25 '06 #3
You were right Matt, it works. I tried something similar a while ago but
forgot to place the cs in app_code.
Not enought experience with ASP.net assumingly.

"Ivonne Riedel" <iv***********@t-online.de> schrieb im Newsbeitrag
news:dr*************@news.t-online.com...
Hi Matt,

I read in an article that it should be possible (various ones to be
precise).
E.g. http://cs.swan.ac.uk/~csneal/Reliabl...ceExample.html
I will try the second option you gave me as I needed compiled code for
speed matters and to pass parameters.
Thanks so far

Ivonne.

"Matt Dinovo" <matt_at_swiftus_dot_com> schrieb im Newsbeitrag
news:eH**************@TK2MSFTNGP10.phx.gbl...
Due to the new way ASP.NET projects are compiled, you have one of two
choices here:

First, you could combine everything into your ASHX file (see below):

<%@ WebHandler Language="C#" Class="MyNamespace.handlerpur" %>

using System;
using System.Web;

namespace MyNamespace
{
public class handlerpur : IHttpHandler
{
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable
{
get {return false;}
}
}
}

Or you could put the handlerpur.cs file in your App_Code directory so
that it's compiled into the web project DLL and then your ASHX file would
only have the webhandler directive:

<%@ WebHandler Language="C#" Class="MyNamespace.handlerpur" %>

I don't believe that the WebHandler directive allows for 'code behind'
files like a page does.

HTH,

Matt Dinovo

"Ivonne Riedel" <iv***********@t-online.de> wrote in message
news:dr*************@news.t-online.com...
Hi everybody,

I have got a serious problem building an HTTPHandler in codebehind
style.
I made the following steps:
Create an ASP .net Website project
Add a generic handler.
Rewrite this "Hello World" item into codebehind style so that the .ashx
file has the only line:
<%@ WebHandler Language="C#" Class="handlerpur"
CodeBehind="handlerpur.ashx.cs" %>

The codebehind file has the rest of the former content of the ashx file:

using System;
using System.Web;

namespace MyNamespace {
public class handlerpur : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}
}

Trying to build that I get the error:
Could not create type 'myNameSpace.handlerpur' pointing at the first
line of the ashx file.
I checked permissions, the virtual directory on the iis (it has got an
app name), added things to the web.config, checked the framework version
on the iis.
Am I missing something? I do not have a bin directory in my project and
nothing gets compiled.
I am running WinXp SP2, iis 5.1, ASP.net 2.0.50727.

Any help is greatly appreciated

Thanks

Ivonne.



Jan 25 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jed | last post: by
4 posts views Thread by Jeremy Lew | last post: by
9 posts views Thread by Jared Tullis | last post: by
8 posts views Thread by bryan | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.