c#4 目录伪静态

来源:互联网 发布:angularjs 数组合计 编辑:程序博客网 时间:2024/05/08 07:30

1下载URLRewriter.dll到项目的bin目录中

2包含引用(反正我做了,可能非必要)

3在web.config,不要是web.debug.config中进行如下设置

<configuration>--------------------------------------------------------

  <configSections>

    <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter"/>

  </configSections>

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

  <RewriterConfig>

    <Rules>

 

      <RewriterRule>

        <LookFor>~/(\d+)</LookFor>

        <SendTo>~/webform1.aspx?classid=$1</SendTo>

      </RewriterRule>

      <RewriterRule>

        <LookFor>~/(\d+)/(\d+)</LookFor>

        <SendTo>~/webform1.aspx?classid=$1&amp;id=$2</SendTo>

      </RewriterRule>

      

 

    </Rules>

  </RewriterConfig>

   在 <system.web>上面----------------------------------

在    <system.web>里面---------------------------------------

        <compilation debug="true" targetFramework="4.0" />

      <httpHandlers>        

        <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler, URLRewriter"/>        

      </httpHandlers>

      <httpModules>

        <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter"/>        

      </httpModules>

 

注意:

~/(\d+)/(\d+)中的斜杠数量

0 0
原创粉丝点击