Use httpmodule to override the URL

Source: Internet
Author: User
Void context_beginrequest (Object sender, eventargs e) {httpapplication application = (httpapplication) sender; httpcontext context = application. context; httpresponse response = application. response; string Path = context. request. path; string file = system. io. path. getfilename (PATH); RegEx = new RegEx (@ "(\ W +) _ (\ W +) (\ d).html", regexoptions. compiled); RegEx regex2 = new RegEx (@ "(\ w+)).html", Rege Xoptions. compiled); match = RegEx. match (File); match match2 = regex2.match (File); If (match2.success) {string url = match2.groups [1]. value; context. rewritepath (URL + ". aspx ");} If (match. success) {string url = match. groups [1]. value; string parm = match. groups [2]. value; string parmvalue = match. groups [3]. value; string rewritepath = URL + ". aspx? "+ Parm +" = "+ parmvalue; context. rewritepath (rewritepath) ;}# region ihttpmodule member public void dispose () {Throw new notimplementedexception ();} public void Init (httpapplication context) {context. beginrequest + = new eventhandler (context_beginrequest);} # endregion
  1. <Httpmodules>
  2.  <Add Name="Urlrewriter" Type="Urlrewriter"/>
  3.  </Httpmodules>

If you want to implement pseudo-static ing in iisconfiguration, .html ing

Source: http://blog.csdn.net/zhoufoxcn/archive/2009/07/14/4346356.aspx

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.