Niinii Corporation

Sharing tutorial, game and knowledge

  • Home
  • CSS
  • Components
  • JavaScript
  • Customize
  • About Us
  • Contact Us
  • Tutorial
  • Games
    • Digimon Master Online

Tuesday, December 23, 2014

How to hide aspx extension with url routing on asp.net 3.5 C#

Posted by Donny Agus at 12:57 PM Labels: ASP.Net , C# , Programming , Tutorial
Share this
Tweet

After ton's of searching finally i got how to hiding aspx extension, of course on .net framework 3.5. Below here i will guide you how to step by step. Introducing with url routing, this is core of .net library which is function to masked your address into nice url/seo friendly.

First step add this .net reference to your web by clicking add reference

System.Web.Routing version 3.5.0.0

Next step go to your web.config, find and add

<httpmodules>
...
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</httpmodules>


And this

<system.webServer>
...
<modules>
...
<remove name="UrlRoutingModule"/><add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
   
</modules>
...
</system.webServer>


It was done for adding library and web.config, now continuing for adding some code into your web application, next step we need to add a global.asax file into web application by adding new item -> global application class, now add a new method below Application_End

void RegisterRoutes(RouteCollection routes)
        {
            routes.Add(
               "Client Data",
                  new Route("ClientData", new ClientDataRouteHandler())
               );

            //Another route
            //routes.Add(
               //"Task List",
                  //new Route("TaskList", new TaskListRouteHandler())
               //);
        }


Dont forget to add using System.Web.Routing on header global.asax, i was create method RegisterRoutes, first route has 2 paratemer, first parameter ex : "Client Data" to give a unique name for route instance and secound parameter for giving an alias to out aspx file, notice that we have class name ClientDataRouteHandler and we need create it first.

Next create new class ClientDataRouteHandler in your solution in any directory

    public class ClientDataRouteHandler : IRouteHandler
    {
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            return BuildManager.CreateInstanceFromVirtualPath("~/ClientDataForm.aspx", typeof(Page)) as Page;
        }
    }


Don't forget too, add using System.Web.Routing, System.Web.Compilation and System.Web.UI, the real aspx one was ClientDataForm.aspx but i was masked it into ClientData

Last step we need to call RegisterRoute function on Application_Start global.asax

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }


Ok finnaly, try access your url with this route for example i will access with http://localhost:port/ClientData

Thanks, if you have any question please comment below




Related articles


How to completely shutdown in windo...

How to sharing internet connection ...

Cara memblok autoplay pada windows ...

How to import and export oracle dat...
Newer Post Older Post

2 comments :

  1. Ashraz RashidMarch 7, 2015 at 12:48 PM

    In my App have multiple pages..Can i take global class for multiple pages??

    ReplyDelete
    Replies
    1. Donny AgusMarch 30, 2015 at 12:14 AM

      Sure, you can return multiple instance for multiple page routing

      Delete
      Replies
        Reply
    2. Reply
Add comment
Load more...

Subscribe to: Post Comments ( Atom )

Popular Posts

  • PF Clone 15/15 Impmon Beezelmon (Revised)
    PF Clone 15/15 Impmon Beezelmon, thanks to anonymous who was warned me before, impmon(rookie) has bug when clone AT Level 2 better use Meg...
  • Advanced Skill Break with ASPD
    Good days everyone long time no post again, today i will post how to advanced skill break a.k.a asb with aspd actualy using buff Burst U...
  • MC Skin DMO
    Here link download for mc monster card skin Digimon Master Online DG[ON] << Download link Spawn Normal << Download lin...

Blog Archive

  • 2016 ( 1 )
    • December ( 1 )
  • 2015 ( 2 )
    • March ( 1 )
    • January ( 1 )
  • 2014 ( 30 )
    • December ( 5 )
      • Datamon Map Through Wall
      • Red Quadcore Necklace
      • How to hide aspx extension with url routing on asp...
      • PF clone 15/15 Silphymon Jogress
      • MC Skin - Apocalymon mini
    • November ( 7 )
    • October ( 5 )
    • September ( 3 )
    • July ( 1 )
    • June ( 1 )
    • May ( 6 )
    • April ( 2 )
  • 2011 ( 1 )
    • November ( 1 )

Pages

  • Home
  • Digimon Master Online
  • Software
  • Tutorial
  • Games
  • Contact Us
  • About Us

Social Icons

facebooktwitter

Yahoo Messenger

About Me

My photo
Donny Agus
View my complete profile

Followers

Featured Posts


Labels

  • ASP.Net
  • C#
  • Digimon Master Online
  • Dynamics CRM
  • Games
  • MB2-712
  • Microsoft Exam Certification
  • Oracle
  • Programming
  • Tutorial

Popular Posts

  • PF Clone 15/15 Impmon Beezelmon (Revised)
    PF Clone 15/15 Impmon Beezelmon, thanks to anonymous who was warned me before, impmon(rookie) has bug when clone AT Level 2 better use Meg...
  • Advanced Skill Break with ASPD
    Good days everyone long time no post again, today i will post how to advanced skill break a.k.a asb with aspd actualy using buff Burst U...
  • MC Skin DMO
    Here link download for mc monster card skin Digimon Master Online DG[ON] << Download link Spawn Normal << Download lin...

© Niinii Corporation 2014 . Powered by Blogger templates and RWD Testing Tool