By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

Cannot load my custom HttpHandler

P: n/a
I followed the example at http://support.microsoft.com/kb/308001/EN-US/
and created my own HttpHandler.

Here is the code:

using System.Web;

namespace MyNameSpace
{
public class SyncHttpHandler: IHttpHandler
{
public SynHttpHandler()
{
//
// TODO: Add constructor logic here
//
}

public bool IsReusable
{
get { return false; }
}

public void ProcessRequest(HttpContext context)
{
context.Response.Write("Hello from custom HttpHandler.");
}
}
}

I have this (inter alia) in my web.config:

<httpHandlers>
<add verb="*" path="*.sync" type="SyncHttpHandler,
SyncHttpHandler" />
</httpHandlers>

I have added the .sync extension to aspnet_isapi.dll by following the
instruction as well.

Now, when I try to check out my web application, I get this (where
Line 145 is highlighted in red).

Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.

Parser Error Message: Could not load type 'SyncHttpHandler' from
assembly 'SyncHttpHandler'.

Source Error:

Line 143: [snip]
Line 144: [snip]
Line 145: <add verb="*" path="*.sync"
type="SyncHttpHandler, SyncHttpHandler" />
Line 146: </httpHandlers>
Line 147: <httpModules>

So, what am I missing?

TALIA=Thanks a lot in advance.
Jul 8 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
you used a namespace defining your type, so you must use when specifying the
type.

<add verb="*"
path="*.sync"
type="MyNameSpace.SyncHttpHandler, SyncHttpHandler" />
-- bruce (sqlwork.com)
"Author" wrote:
I followed the example at http://support.microsoft.com/kb/308001/EN-US/
and created my own HttpHandler.

Here is the code:

using System.Web;

namespace MyNameSpace
{
public class SyncHttpHandler: IHttpHandler
{
public SynHttpHandler()
{
//
// TODO: Add constructor logic here
//
}

public bool IsReusable
{
get { return false; }
}

public void ProcessRequest(HttpContext context)
{
context.Response.Write("Hello from custom HttpHandler.");
}
}
}

I have this (inter alia) in my web.config:

<httpHandlers>
<add verb="*" path="*.sync" type="SyncHttpHandler,
SyncHttpHandler" />
</httpHandlers>

I have added the .sync extension to aspnet_isapi.dll by following the
instruction as well.

Now, when I try to check out my web application, I get this (where
Line 145 is highlighted in red).

Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.

Parser Error Message: Could not load type 'SyncHttpHandler' from
assembly 'SyncHttpHandler'.

Source Error:

Line 143: [snip]
Line 144: [snip]
Line 145: <add verb="*" path="*.sync"
type="SyncHttpHandler, SyncHttpHandler" />
Line 146: </httpHandlers>
Line 147: <httpModules>

So, what am I missing?

TALIA=Thanks a lot in advance.
Jul 8 '08 #2

P: n/a
On Jul 8, 5:44*pm, bruce barker
<brucebar...@discussions.microsoft.comwrote:
you used a namespace defining your type, so you must use when specifying the
type.

*<add verb="*"
* * path="*.sync"
* * type="MyNameSpace.SyncHttpHandler, SyncHttpHandler" />

-- bruce (sqlwork.com)

"Author" wrote:
I followed the example athttp://support.microsoft.com/kb/308001/EN-US/
and created my own HttpHandler.
Here is the code:
using System.Web;
namespace MyNameSpace
{
* * public class SyncHttpHandler: IHttpHandler
* * {
* * * * public SynHttpHandler()
* * * * {
* * * * * * //
* * * * * * // TODO: Add constructor logic here
* * * * * * //
* * * * }
* * * * public bool IsReusable
* * * * {
* * * * * * get { return false; }
* * * * }
* * * * public void ProcessRequest(HttpContext context)
* * * * {
* * * * * * context.Response.Write("Hello from custom HttpHandler.");
* * * * }
* * }
}
I have this (inter alia) in my web.config:
<httpHandlers>
* * * * * * <add verb="*" path="*.sync" type="SyncHttpHandler,
SyncHttpHandler" />
</httpHandlers>
I have added the .sync extension to aspnet_isapi.dll by following the
instruction as well.
Now, when I try to check out my web application, I get this (where
Line 145 is highlighted in red).
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: Could not load type 'SyncHttpHandler' from
assembly 'SyncHttpHandler'.
Source Error:
Line 143: [snip]
Line 144: [snip]
Line 145: * * * * * *<add verb="*" path="*.sync"
type="SyncHttpHandler, SyncHttpHandler" />
Line 146: * * * *</httpHandlers>
Line 147: * * * *<httpModules>
So, what am I missing?
TALIA=Thanks a lot in advance.
Yes, that was the problem. Thank you.

One more question. In this dumb example, the ProcessRequest method
simply outputs that silly "Hello from custom HttpHandler" sentence.
Normally, in the real world, what kind of stuff do we do in this
method?

Jul 9 '08 #3

P: n/a
On Jul 8, 5:44*pm, bruce barker
<brucebar...@discussions.microsoft.comwrote:
you used a namespace defining your type, so you must use when specifying the
type.

*<add verb="*"
* * path="*.sync"
* * type="MyNameSpace.SyncHttpHandler, SyncHttpHandler" />

-- bruce (sqlwork.com)

"Author" wrote:
I followed the example athttp://support.microsoft.com/kb/308001/EN-US/
and created my own HttpHandler.
Here is the code:
using System.Web;
namespace MyNameSpace
{
* * public class SyncHttpHandler: IHttpHandler
* * {
* * * * public SynHttpHandler()
* * * * {
* * * * * * //
* * * * * * // TODO: Add constructor logic here
* * * * * * //
* * * * }
* * * * public bool IsReusable
* * * * {
* * * * * * get { return false; }
* * * * }
* * * * public void ProcessRequest(HttpContext context)
* * * * {
* * * * * * context.Response.Write("Hello from custom HttpHandler.");
* * * * }
* * }
}
I have this (inter alia) in my web.config:
<httpHandlers>
* * * * * * <add verb="*" path="*.sync" type="SyncHttpHandler,
SyncHttpHandler" />
</httpHandlers>
I have added the .sync extension to aspnet_isapi.dll by following the
instruction as well.
Now, when I try to check out my web application, I get this (where
Line 145 is highlighted in red).
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: Could not load type 'SyncHttpHandler' from
assembly 'SyncHttpHandler'.
Source Error:
Line 143: [snip]
Line 144: [snip]
Line 145: * * * * * *<add verb="*" path="*.sync"
type="SyncHttpHandler, SyncHttpHandler" />
Line 146: * * * *</httpHandlers>
Line 147: * * * *<httpModules>
So, what am I missing?
TALIA=Thanks a lot in advance.
After a little research of IHttpHandler, I think that mostly it is
used to do URL Rewriting. What else other than this?

Also, the C# example given at http://msdn.microsoft.com/en-us/libr...6d(VS.80).aspx
showing below:

void Button_Click(Object sender,EventArgs e)
{
Response.Write("Data submitted to this page");
}

void Page_Load(Object sender,EventArgs e)
{

// Rewrite the internal path to send the client
// to the page passed to the RewritePath method.
Context.RewritePath("HttpContext_Next.aspx");
}

I am confused by this Page_Load implementation. How is

Context.RewritePath("whatever_page.aspx");

gonna work in Page_Load of an aspx web page? Shouldn't it be in the
ProcessRequest method of a class of type IHttpHandler?

BTW, google newsgroup is sorta slow these two days. It takes about 12
hours for a post to show up.
Jul 9 '08 #4

P: n/a
On Jul 9, 12:11*pm, Author <gnewsgr...@gmail.comwrote:
On Jul 8, 5:44*pm, bruce barker

<brucebar...@discussions.microsoft.comwrote:
you used a namespace defining your type, so you must use when specifying the
type.
*<add verb="*"
* * path="*.sync"
* * type="MyNameSpace.SyncHttpHandler, SyncHttpHandler" />
-- bruce (sqlwork.com)
"Author" wrote:
I followed the example athttp://support.microsoft.com/kb/308001/EN-US/
and created my own HttpHandler.
Here is the code:
using System.Web;
namespace MyNameSpace
{
* * public class SyncHttpHandler: IHttpHandler
* * {
* * * * public SynHttpHandler()
* * * * {
* * * * * * //
* * * * * * // TODO: Add constructor logic here
* * * * * * //
* * * * }
* * * * public bool IsReusable
* * * * {
* * * * * * get { return false; }
* * * * }
* * * * public void ProcessRequest(HttpContext context)
* * * * {
* * * * * * context.Response.Write("Hello from custom HttpHandler.");
* * * * }
* * }
}
I have this (inter alia) in my web.config:
<httpHandlers>
* * * * * * <add verb="*" path="*.sync" type="SyncHttpHandler,
SyncHttpHandler" />
</httpHandlers>
I have added the .sync extension to aspnet_isapi.dll by following the
instruction as well.
Now, when I try to check out my web application, I get this (where
Line 145 is highlighted in red).
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: Could not load type 'SyncHttpHandler' from
assembly 'SyncHttpHandler'.
Source Error:
Line 143: [snip]
Line 144: [snip]
Line 145: * * * * * *<add verb="*" path="*.sync"
type="SyncHttpHandler, SyncHttpHandler" />
Line 146: * * * *</httpHandlers>
Line 147: * * * *<httpModules>
So, what am I missing?
TALIA=Thanks a lot in advance.

After a little research of IHttpHandler, I think that mostly it is
used to do URL Rewriting. *What else other than this?

Also, the C# example given athttp://msdn.microsoft.com/en-us/library/sa5wkk6d(VS.80).aspx
showing below:

void Button_Click(Object sender,EventArgs e)
{
* *Response.Write("Data submitted to this page");

}

void Page_Load(Object sender,EventArgs e)
{

* *// Rewrite the internal path to send the client
* *// to the page passed to the RewritePath method.
* *Context.RewritePath("HttpContext_Next.aspx");

}

I am confused by this Page_Load implementation. *How is

Context.RewritePath("whatever_page.aspx");

gonna work in Page_Load of an aspx web page? *Shouldn't it be in the
ProcessRequest method of a class of type IHttpHandler?

BTW, google newsgroup is sorta slow these two days. *It takes about 12
hours for a post to show up.
Well this one did show up quick, but before this one I replied to
bruce and thanked him/you for pointing out the mistake, which hasn't
shown up yet. Google is getting shaky.

BTW, I tried the following in my HttpHandler

public void ProcessRequest(HttpContext context)
{
//context.Response.Write("Hello from custom
HttpHandler.");
if (context.Request.RawUrl.ToLower().Contains("sync") )
{
context.RewritePath("~\index.aspx");
}
}

And then when I tried to request a page such as Default.sync, it shows
me a blank page, instead of what I was expecting to see in
index.aspx. Not sure what is going on.
Jul 9 '08 #5

P: n/a
On Jul 9, 12:51*pm, Author <gnewsgr...@gmail.comwrote:
On Jul 9, 12:11*pm, Author <gnewsgr...@gmail.comwrote:
On Jul 8, 5:44*pm, bruce barker
<brucebar...@discussions.microsoft.comwrote:
you used a namespace defining your type, so you must use when specifying the
type.
*<add verb="*"
* * path="*.sync"
* * type="MyNameSpace.SyncHttpHandler, SyncHttpHandler" />
-- bruce (sqlwork.com)
"Author" wrote:
I followed the example athttp://support.microsoft.com/kb/308001/EN-US/
and created my own HttpHandler.
Here is the code:
using System.Web;
namespace MyNameSpace
{
* * public class SyncHttpHandler: IHttpHandler
* * {
* * * * public SynHttpHandler()
* * * * {
* * * * * * //
* * * * * * // TODO: Add constructor logic here
* * * * * * //
* * * * }
* * * * public bool IsReusable
* * * * {
* * * * * * get { return false; }
* * * * }
* * * * public void ProcessRequest(HttpContext context)
* * * * {
* * * * * * context.Response.Write("Hello from custom HttpHandler.");
* * * * }
* * }
}
I have this (inter alia) in my web.config:
<httpHandlers>
* * * * * * <add verb="*" path="*.sync" type="SyncHttpHandler,
SyncHttpHandler" />
</httpHandlers>
I have added the .sync extension to aspnet_isapi.dll by following the
instruction as well.
Now, when I try to check out my web application, I get this (where
Line 145 is highlighted in red).
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: Could not load type 'SyncHttpHandler' from
assembly 'SyncHttpHandler'.
Source Error:
Line 143: [snip]
Line 144: [snip]
Line 145: * * * * * *<add verb="*" path="*.sync"
type="SyncHttpHandler, SyncHttpHandler" />
Line 146: * * * *</httpHandlers>
Line 147: * * * *<httpModules>
So, what am I missing?
TALIA=Thanks a lot in advance.
After a little research of IHttpHandler, I think that mostly it is
used to do URL Rewriting. *What else other than this?
Also, the C# example given athttp://msdn.microsoft.com/en-us/library/sa5wkk6d(VS.80).aspx
showing below:
void Button_Click(Object sender,EventArgs e)
{
* *Response.Write("Data submitted to this page");
}
void Page_Load(Object sender,EventArgs e)
{
* *// Rewrite the internal path to send the client
* *// to the page passed to the RewritePath method.
* *Context.RewritePath("HttpContext_Next.aspx");
}
I am confused by this Page_Load implementation. *How is
Context.RewritePath("whatever_page.aspx");
gonna work in Page_Load of an aspx web page? *Shouldn't it be in the
ProcessRequest method of a class of type IHttpHandler?
BTW, google newsgroup is sorta slow these two days. *It takes about 12
hours for a post to show up.

Well this one did show up quick, but before this one I replied to
bruce and thanked him/you for pointing out the mistake, which hasn't
shown up yet. *Google is getting shaky.

BTW, I tried the following in my HttpHandler

* * *public void ProcessRequest(HttpContext context)
* * * * {
* * * * * * //context.Response.Write("Hello from custom
HttpHandler.");
* * * * * * if (context.Request.RawUrl.ToLower().Contains("sync") )
* * * * * * {
* * * * * * * * context.RewritePath("~\index.aspx");
* * * * * * }
* * * * }

And then when I tried to request a page such as Default.sync, it shows
me a blank page, instead of what I was expecting to see in
index.aspx. *Not sure what is going on.
OK, have to do a recursive call to ProcessRequest like so:

public void ProcessRequest(HttpContext context)
{
//context.Response.Write("Hello from custom
HttpHandler.");
if (context.Request.RawUrl.ToLower().Contains("sync") )
{
context.RewritePath("~/index.aspx");
IHttpHandler handler =
System.Web.UI.PageParser.GetCompiledPageInstance(" ~/index.aspx", null,
context );
handler.ProcessRequest(context);
}
}

Not sure why a recursive call to ProcessRequest is needed.
Jul 9 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.