About URL rewriting implemented by httpmodule and httphandler in ASP. NET

Source: Internet
Author: User
Http://dotnet.chinaitlab.com/ASPNET/529952.html

About httpmodule and httphandler
One of the things that ASP. NET must know (httpmodule, httphandler)
ASP. NET (httpmodule, httphandler) 2
Httphandler httpmodule makes a webpage with its own suffix!
Learn httphandler and httpmodule
ASP. NET: httpmodule, httphandler
C # enhanced series Article 8: simple use of httpmodule, httphandler, and httphandlerfactory

Http://www.cnblogs.com/huoxingren/archive/2007/02/14/649906.html
Asp.net httpmodule and httphander

Practical HTTP handler (HTTP handler) (6) -- random bar code
Actual HTTP handler (HTTP handler) (5) -- directly open the dynamically generated file without using temporary files
Practice HTTP handler (4) -- share session with web programs
HTTP handler (3) -- dynamically generate images
HTTP ProcessingProgram(HTTP handler) (2) -- passing parameters to the HTTP handler<-You are here.
HTTP handler (1) -- create the simplest HTTP handler

1.1 Basic concepts of ASP. Net-HTTP runtime and page execution modelAuthor: wenye

  • 1.1 learning basic concepts of ASP. NET -- httpmoduleAuthor: wenye
  • 1.1 learning basic concepts of ASP. NET -- httphandlerAuthor: wenye
  • 1.1 learning ASP. NET series (continuous update)Author: wenye
  • 1.1 learning ASP. NET example -- httpmodule exampleAuthor: wenye
  • 1.1 learning basic concepts of ASP. NET-DelegationAuthor: wenye
  • 1.1 learning basic concepts of ASP. NET-EventsAuthor: wenye

     

  • ASP. NET three-tier Web Application Development-part.1By Jimmy Zhang
  • [Editing] creating and using RSS sources on a web siteBy Jimmy Zhang
  • ASP. NET architecture (HTTP handler introduction)-Part.2By Jimmy Zhang
  • ASP. NET architecture (HTTP request processing process)-part.1By Jimmy Zhang
  • ASP. NET architecture (httpmodule introduction)-part.3By Jimmy Zhang
  • [Post] httphandler for custom HTTP processing and Applications in ASP. NET
    [Post] ASP. NET custom HTTP processing and application httpmodule

     

     

    -------------------------------------------------------

    What is httphandler used? Interesting

    First look at a concise from: http://www.i170.com/user/interface/Article_3069
    What does httphandler do? I won't say much about finding a lot of materials using any search engine. I will write some of my current learning experiences here, hoping to get to know httphandler from the other side.
    The so-called httphandler is actually used by. Net to process page requests. You can think about it. Only files with the. aspx suffix can be protected by Forms authentication, while files with the. config suffix are not accessible. All of these are handled by some httphandler built in Asp.net. The reason why we need to learn to use httphandler is mainly because we want to handle some HTTP requests on our own.
    Search for "httphandler. Net" from Google. The following are the purposes of httphandler:
    1. Prevent leeching. It mainly prevents image leeching.
    2. Use URL rewriting. I haven't looked at this carefully. The general meaning is that the URL can be switched to the correct address, for example, to shorten a long URL so that a nonexistent URL is redirected to an error or default address.
    3. Perform short and convenient operations. For example, some Article Use httphandler to log out.
    4. Wait.
    As one of the core HTTP processing capabilities of Asp.net, httphandler has more functions than that. I recently want to learn httphandler mainly because of my job (I want to graduate, Hoho ...) you need to use this to process custom extension files, such as http: // localhost/hello. for a webpage such as notus, the suffix names of all pages on the site are used. notus, in order to use the custom page generation method (mainly when the page is generated using XML + XSLT ).
    I 've mentioned some of the functions of httphandler. Next I'll take a look at what I learned today. I dare say that there must be something you need, because it's something I 've learned for a long time (what, at that time, everyone knew it at first glance? Is it true that I am the dumbest ?)
    Check. net SDK documentation, you will find that there are ihttphandler and ihttphandlerfactory, the first is the interface that needs to be implemented by the custom httphandler, followed by the interface that needs to be implemented by the custom factory that returns httphandler, these two items are on the web. the registration methods in config are the same. I am very familiar with the former. What is the factory behind?
    The answer is to return an httphandler (......).
    What does the returned httphandler do?
    The answer is to process the current HTTP request.
    Since both processes the current HTTP request, why not use ihttphandler directly?
    I don't know.
    What is a factory?
    Is it the factory model?
    What is the factory model?
    Appropriate products can be returned based on customer needs.
    So what is the role of ihttphandlerfactory?
    Well, return the appropriate httphandler based on the current HTTP request.
    That's what it means. For example, http: // localhost/hello. the notus URL is specially processed. when the request is sent to this URL, the factory returns the httphandler that processes Hello separately, but other URLs, and returns a common httphandler.
    Below is a simple Code Example:
    System. Web. ihttphandler gethandler (system. Web. httpcontext context, string requesttype, string URL, string pathtranslated)
    {
    // Full name of the file
    String fname = URL. substring (URL. lastindexof ("/") + 1 );
    // File name
    String cname = fname. substring (0, fname. indexof ("."));
    // Return the appropriate httphandler as needed
    If (cname = "hello ")
    Return new handlerhello ();
    Else
    Return new handlercommon ();
    }

    Here is a more specific article on csdn, which uses httphandler for URL rewriting:
    Http://dev.csdn.net/develop/article/45/45585.shtm

    Bytes ------------------------------------------------------------------------------------

     

    ASP. NET pure code implements pseudo static address (URL rewriting)

    Complete parsing of URL rewriting in ASP. net2.0

    Simple and practical URL rewriting (urlrewriter. dll)

  • Urlrewritingnet perfectly implements URL rewriting (ing) in ASP. NET 2.0)

  • Msdn http://msdn.microsoft.com/zh-cn/library/ms972974.aspx.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.