Friday, 27 March 2015

URL Mapping in ASP.NET

Use the code in web.config:

<?xml version="1.0"?>
<!--
     This tutorial is sponsored by http://www.ServerIntellect.com web hosting.
     Check out http://v4.aspnettutorials.com/ for more great tutorials!
  -->
<configuration>
    <system.web>
        <urlMappings enabled="true">
            <add url="~/Home" mappedUrl="~/home.aspx"/>
            <add url="~/About" mappedUrl="~/about.aspx"/>
        </urlMappings>
        <compilation debug="true" targetFramework="4.0"/>
    </system.web>
</configuration>


Use the code in ASPX page:
  <asp:HyperLink ID="hlHome" runat="server" NavigateUrl="~/Home">Home</asp:HyperLink>
        <br />
        <asp:HyperLink ID="hlAbout" runat="server"  NavigateUrl="~/About">About
</asp:HyperLink>

No comments:

Post a Comment