简体   繁体   中英

ASPX Mapping in web.config

I've searched around for an answer to this question for a while. I'm working on a VB.NET project and I have several .aspx files I would like to map to different url paths. Is there a tagline for the mapping in the web.config file similar to mapping .jsp with web.xml in java:

<servlet>
    <servlet-name>myjsp</servlet-name>
    <jsp-file>/hello.jsp</jsp-file>
</servlet>

<servlet-mapping>
    <servlet-name>sample</servlet-name>
    <url-pattern>/Hello</url-pattern>
</servlet-mapping>

Edit: I believe I can achieve what I am trying to do through UrlRewriter, but I cannot get this configuration to work because I do not know what references I have to make (Intelligencia.UrlRewriter doesn't exist as a reference assembly?)

 <configSections>
    <section name="rewriter"  
         requirePermission="false" 
            type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
 </configSections>

  <system.web>
<httpModules>
  <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
</httpModules>

  </system.web>

   <rewriter>
     <rewrite url="WebForm1.aspx" to="WebForm1/" />
     <rewrite url="~/products/CDs.aspx" to="~/products.aspx?category=CDs" />
     <rewrite url="~/products/DVDs.aspx" to="~/products.aspx?category=DVDs" />
   </rewriter>  

It is also my understanding that if you are using IIS7, you have to replace the httpModule section with

 <system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
  <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
</modules>
 </system.webServer>

to Map ~/WebForm1.aspx to ~/Web

<configSections>
  <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
</configSections>
<system.web>
<httpModules>
  <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
</httpModules>
<compilation debug="true"/>
<urlMappings enabled="true">
 <add url="~/Web" mappedUrl="~/WebForm1.aspx" />
</urlMappings>
  </system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
  <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule"/>
</modules>
<!-- THE FOLLOWING LINE MUST BE PRESENT FOR AJAX & VALIDATION TO WORK WITH URLREWRITER.NET -->
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<!--</handlers>-->
</system.webServer>
<!-- URL REWRITER -->
<rewriter>
  <!--<rewrite url="~/WebForm1.aspx" to="~/WebForm2.aspx"/>-->
</rewriter>

Inside of Configuration tags where the noted rewrite node will redirect, the name is modified by the URL mapping

This requires a reference made to Intelligencia.UrlRewriter to forward urls (but not rename), which I found on github.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM