|
|
|
date: Tue, 8 Jul 2008 14:21:10 -0700 (PDT),
group: microsoft.public.dotnet.framework.aspnet
back
Re: Cannot load my custom HttpHandler
On Jul 8, 5:44 pm, bruce barker
wrote:
> 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?
date: Wed, 9 Jul 2008 07:43:56 -0700 (PDT)
author: Author
Re: Cannot load my custom HttpHandler
On Jul 8, 5:44 pm, bruce barker
wrote:
> 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/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.
date: Wed, 9 Jul 2008 09:11:34 -0700 (PDT)
author: Author
Re: Cannot load my custom HttpHandler
On Jul 9, 12:11 pm, Author wrote:
> On Jul 8, 5:44 pm, bruce barker
>
>
>
> wrote:
> > 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.
date: Wed, 9 Jul 2008 09:51:47 -0700 (PDT)
author: Author
Re: Cannot load my custom HttpHandler
On Jul 9, 12:51 pm, Author wrote:
> On Jul 9, 12:11 pm, Author wrote:
>
>
>
> > On Jul 8, 5:44 pm, bruce barker
>
> > wrote:
> > > 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.
date: Wed, 9 Jul 2008 10:04:30 -0700 (PDT)
author: Author
|
|