简体   繁体   中英

Url rewrite doesn't work

I have tried to rewrite the URL but if I run my application on the
localhost they don't change

<system.web>
        <urlMappings enabled="true">
          <clear/>
          <!--Account-->
          <add url="~/Paswoord" mappedUrl="~/Account/ChangePassword.aspx"/>
          <!--Admin-->
          <add url="~/AddUsers" mappedUrl="~/Admin/AddUser.aspx"/>
          <add url="~/DeleteUsers" mappedUrl="~/Admin/DeleteUser.aspx"/>
    </urlMappings>
    <system.web>

I think you should try this

http://www.urlrewriting.net/160/en/documentation.html

and download documentation given and try accordingly....

I think the problem is that url is not pointing to an aspx page. Try

  <!--Account-->
  <add url="~/Paswoord.aspx" mappedUrl="~/Account/ChangePassword.aspx"/>
  <!--Admin-->
  <add url="~/AddUsers.aspx" mappedUrl="~/Admin/AddUser.aspx"/>
  <add url="~/DeleteUsers.aspx" mappedUrl="~/Admin/DeleteUser.aspx"/>

This works
Default.aspx:

   <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Password">HyperLink</asp:HyperLink>
  <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/AddUsers">HyperLink</asp:HyperLink>
  <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/DeleteUsers">HyperLink</asp:HyperLink>

webconfig:

 <system.web>
            <urlMappings enabled="true">
              <clear/>
              <!--Account-->
              <add url="~/Password" mappedUrl="~/Account/ChangePassword.aspx"/>
              <!--Admin-->
              <add url="~/AddUsers" mappedUrl="~/Admin/AddUser.aspx"/>
              <add url="~/DeleteUsers" mappedUrl="~/Admin/DeleteUser.aspx"/>
        </urlMappings>
    <system.web>

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