I want to write a custom HTTP Handler in ASP.Net (I'm using C# currently) that filters all requests to, say, .aspx files, and then, depending on the page name that comes with the requests, I redirect the user to a page.
So far, I've written a handler that filter "*", that is, everything. Let's say I receive a request for "Page.aspx", and want to send the user to "AnotherPage.aspx". So I call Redirect on that response and pass "AnotherPage.aspx" as the new page. The problem is that this will once more trigger my handler, which will do nothing. 开发者_如何学编程This will leave the user without any response.
So, is there a way to send the request to the other handlers (cascade the message) once I've dealt with it?
Thanks, Bruno
Page.PreviousPage or Page.IsCrossPagePostBack should let you know.
Since Mark hasn't provided a full anwer containing the advice on MVC, here it goes what I learned:
ASP.Net MVC can do that. In fact, ASP.Net MVC was designed for that purpose: with MVC you can map different sub-links in your website to the same Controller, which will then process the request and send a view (page) back to the user. This technique is called Url Routing and is explained in ScottGu's blog quite well.
Scott's also have other articles describing MVC, which are worth checking out.
精彩评论