URL Mapping In ASP.Net 2.0

  • URL Mapping :

          URL Mapping is a new feature introduced in ASP.NET 2.0. you can change your URL more understanding purpose Example you can generally write http://localhost/UrlMapping/Detail.aspx?Id=1 In this URL we passing a query string value when any user see this url it like some improper. you can improve this using the URL Mapping http://localhost/UrlMapping/one.aspx in our application there is no aspx page like one.aspx. we just mapped that page.

Steps :

1) Create Web Application Using (Asp.net 2.0 with C#).

2) put below control in to Page (default.aspx)

   1: <table align="center">
   2:              <tr>
   3:                  <td style="font-size: 16px; color: blue" bgcolor="#ffffff" bordercolor="#ff9900"
   4:                      nowrap="noWrap">
   5:                      Get Detail Information
   6:                  </td>
   7:              </tr>
   8:              <tr>
   9:                  <td style="width: 147px">
  10:                      <asp:Button ID="btnd1" runat="server" Font-Bold="True" Text="Detail 1" OnClick="btnd1_Click" />
  11:                  </td>
  12:              </tr>
  13:              <tr>
  14:                  <td style="width: 147px">
  15:                      <asp:Button ID="btnd2" runat="server" Font-Bold="True" Text="Detail 2" OnClick="btnd2_Click" />
  16:                  </td>
  17:              </tr>
  18:              <tr>
  19:                  <td style="width: 147px">
  20:                      <asp:Button ID="btnd3" runat="server" Font-Bold="True" Text="Detail 3" OnClick="btnd3_Click" />
  21:                  </td>
  22:              </tr>
  23:              <tr>
  24:                  <td style="width: 147px">
  25:                      <asp:Button ID="btnd4" runat="server" Font-Bold="True" Text="Detail 4" OnClick="btnd4_Click" />
  26:                  </td>
  27:              </tr>
  28:          </table>

3) put below code in to CS (default.cs).

   1: protected void btnd1_Click(object sender, EventArgs e)
   2:     {
   3:         Response.Redirect("~/one.aspx");
   4:     }
   5:     protected void btnd2_Click(object sender, EventArgs e)
   6:     {
   7:         Response.Redirect("~/two.aspx");
   8:     }
   9:     protected void btnd3_Click(object sender, EventArgs e)
  10:     {
  11:         Response.Redirect("~/three.aspx");
  12:     }
  13:     protected void btnd4_Click(object sender, EventArgs e)
  14:     {
  15:         Response.Redirect("~/four.aspx");
  16:     }

4) add new page detail.aspx.

5) now the main thing where you map this url because there is no page like one.aspx,two.aspx,three.aspx,four.aspx. 

6) now in the web config file you put below code in between <system.web> and </system.web>

 

   1: <urlMappings enabled="true" >
   2:     <!--url which you want mappedURL = transfered url location -->
   3:     <add mappedUrl="~/Detail.aspx?id=1" url="~/one.aspx"/>
   4:     <add mappedUrl="~/Detail.aspx?id=2" url="~/two.aspx"/>
   5:     <add mappedUrl="~/Detail.aspx?id=3" url="~/three.aspx"/>
   6:     <add mappedUrl="~/Detail.aspx?id=4" url="~/four.aspx"/>
   7:   </urlMappings>

 

Thanks.

Advertisements

3 comments

  1. cwxwwwxdfvwwxwx · · Reply

    well, hi admin adn people nice forum indeed. how’s life? hope it’s introduce branch 😉

    1. hi,
      thank you very much. life is good. why about your life?
      i m not getting what you say? if any doubt’s regarding post or any information missing in the post then please tell freely. i have try to improve that things.

      thnx

  2. Arunkumar.S · · Reply

    Thanks for your information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s