advertisement

Forum => Article discussions => Rewriting the URL using IHttpHandlerFactory

Jump to:

Next Oldest | Next Newest

More: |< <<  1  2  3  4  
2/21/2006 11:42:45 AM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

Yes, you can use folders like that, but you need to set the wildcard map in IIS to point to ASP.NET. I currently do this on my blog site.


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

7/12/2006 6:59:38 PM Link | Reply | Edit | Quote

JonB101

Profile Send Private Message Send E-Mail
Location: | Joined: 10/12/2005 | Posts: 12 | Offline

I could never get past the performance issues this solution caused my site. In the end I used this simple method, and it works. We have used this for the last 4 months or so, and have had no issues. I wish i could use the factory, because of its clean and profesional interface. Oh well.....

Thank you Jeff for your time & help.


The code snippet below should get you started.

Global.asax.vb --> Application_BeginRequest


Context.Items("forumID") = intForumID
Context.Current.RewritePath("forums.aspx")

forums.aspx.vb -->pageLoad

intForumID = CInt(HttpContext.Current.Items("forumID"))
context.Current.RewritePath("forums-" & intForumID.ToString & ".aspx") *** Edited 7/12/2006 11:05:49 PM UTC by JonB101***


test2

7/12/2006 7:52:44 PM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

What "performance issues" are you speaking of? That's pretty ridiculous to write off the entire solution without any explanation. I've been doing it for a long time without issues. You'll have to explain yourself.


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

7/12/2006 10:48:52 PM Link | Reply | Edit | Quote

JonB101

Profile Send Private Message Send E-Mail
Location: | Joined: 10/12/2005 | Posts: 12 | Offline

Refer back to earlier posts/conversations around October 05 and Jannuary 06...


test2

7/13/2006 10:23:07 AM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

You said the problem was you were running in debug mode. Again... you weren't able to directly trace your performance issues to this.


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

7/13/2006 11:25:36 AM Link | Reply | Edit | Quote

JonB101

Profile Send Private Message Send E-Mail
Location: | Joined: 10/12/2005 | Posts: 12 | Offline

Keep on reading the later posts...

After posting here in January, and many many revisions to the handler, I finally gave up and started to look for another solution. The problem was so pronounced that we had IIS restarting twice daily. If IIS was not restarted, we would get system out of memory errors. On day one of rolling out the new method, we no longer had any performance issues.


test2

7/13/2006 4:04:49 PM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

But the very fact that I can run the same code and not have any issues at all means that the problem is deeper than that. Turning things on and off don't automagically point out the underlying problem.


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

7/13/2006 5:28:10 PM Link | Reply | Edit | Quote

JonB101

Profile Send Private Message Send E-Mail
Location: | Joined: 10/12/2005 | Posts: 12 | Offline

We get a million page views a day and tons of dynamic content. When first implemented, we had less traffic and no issues with the handler. As traffic and the amount of dynamic content increased, so did the memory leak. Do people have this code running on a similar or larger sites? Is the problem deeper, or just directly related to the amt of traffic?

Someone contacted me through this forum, and asked if i had found a solution to the memory leak. He was having similar issues. So I came back to share an alternate method.


test2

7/13/2006 5:40:52 PM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

I've got similar code running on handlers that process not only page requests but also image requests, and yes, with a million views.

The highest I've seen w3wp.exe do is around 100 MB. Hardly a machine killing amount. *** Edited 7/13/2006 9:41:57 PM UTC by Jeff***


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

7/26/2006 11:59:53 AM Link | Reply | Edit | Quote

CactusJuice

Profile Send Private Message Send E-Mail Web Site
Location: Phoenix, AZ | Joined: 9/5/2004 | Posts: 107 | Offline

This line chokes when I compile. Error is "cannot convert from object to string.
TheLiteral.Text = HttpContext.Current.Items["fileName"];

If I try:
TheLiteral.Text = HttpContext.Current.Items["fileName"].ToString;

Then this line throws an "object reference not set to an instance error". That one has me stumped.

Cameron

7/27/2006 9:42:45 AM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

Then there isn't an item in the collection named fileName, that's what the object reference exception is about. You might think it's there, but it's not, so something else along the line isn't firing.


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

9/21/2007 4:01:45 PM Link | Reply | Edit | Quote

Zak

Profile Send Private Message Send E-Mail
Location: | Joined: 11/22/2006 | Posts: 5 | Offline

I must be so close, but I just can't get it.

First, App_Code\MyPageFactory.vb:

Imports System
Imports System.IO
Imports System.Web
Imports System.Web.UI
Imports Microsoft.VisualBasic

Public Class MyPageFactory
Implements IHttpHandlerFactory

Public Function GetHandler(ByVal context As System.Web.HttpContext, ByVal requestType As String, ByVal url As String, ByVal pathTranslated As String) As System.Web.IHttpHandler Implements System.Web.IHttpHandlerFactory.GetHandler
context.Items("FileName") = Path.GetFileNameWithoutExtension(url).ToLower

Return PageParser.GetCompiledPageInstance(url, context.Server.MapPath("~/City.aspx"), context)
End Function

Public Sub ReleaseHandler(ByVal handler As System.Web.IHttpHandler) Implements System.Web.IHttpHandlerFactory.ReleaseHandler

End Sub
End Class

The web.config:
<add verb="*" path="Belmont/*.aspx" type="MyPageFactory"/>

So I try to load up http://localhost/politics/Belmont/Default.aspx but all I get is a 404 error.

I've verified that politics is an IIS application.

Any ideas?

9/24/2007 10:07:36 AM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

Your web.config entry isn't the same as your URL. Where is the politics?


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

9/24/2007 10:10:00 AM Link | Reply | Edit | Quote

Zak

Profile Send Private Message Send E-Mail
Location: | Joined: 11/22/2006 | Posts: 5 | Offline

Politics is the name of the Application so I don't need it... correct?

9/24/2007 9:53:43 PM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

Are you sure? I'd try it with it just to make sure.


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

9/25/2007 8:19:33 AM Link | Reply | Edit | Quote

Zak

Profile Send Private Message Send E-Mail
Location: | Joined: 11/22/2006 | Posts: 5 | Offline

I tried it with the politics... same 404 error

9/25/2007 10:12:02 AM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

Well, step through the code and make sure it's all looking where it should.


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

8/3/2008 8:13:26 PM Link | Reply | Edit | Quote

rafiz

Profile Send Private Message Send E-Mail
Location: | Joined: 8/3/2008 | Posts: 1 | Offline

I also got this error:


Line 5:
Line 6: <httpHandlers>
Line 7: <add verb="*" path="~/*.aspx" type="MyPageFactory" />
Line 8: </httpHandlers>
Line 9:

***************************
........Rafiz

How can solve it???....

<a herf= "http://www.uberasp.net" RAFIZ</a>

8/4/2008 12:28:19 PM Link | Reply | Edit | Quote

Jeff

Profile Send Private Message Send E-Mail Web Site AOL Instant Message Yahoo Instant Message ICQ Message
Location: Cleveland, OH, USA | Joined: 8/15/2000 | Posts: 813 | Offline

Don't use the ~.


Jeff 'Jones' Putz
POP World Media, LLC
Maximizing ASP.NET

More: |< <<  1  2  3  4  

Forum => Article discussions => Rewriting the URL using IHttpHandlerFactory

Please login or register to post.