Routing not working on hosting server

Hi All,

Now routing is a common solution in asp.net for URL rewrite. I have used it in many application.

Asp.net application with routing always runs fine on development server. I noticed that sometimes my routes were not working when the application is deployed on the hosting server.

If you will face this kind of problem then use below settings in web.config file. I have configure the UrlRoutingModule and the UrlRoutingHandler in the web.config file manually

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="UrlRoutingModule"/>
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </modules>
    <handlers>
      <add
        name="UrlRoutingHandler"
        preCondition="integratedMode"
        verb="*" path="UrlRouting.axd"
        type="System.Web.HttpForbiddenHandler, System.Web,  
          Version=2.0.0.0, Culture=neutral,  
          PublicKeyToken=b03f5f7f11d50a3a"/>
    </handlers>
    <defaultDocument>
      <files>
        <add value="index.aspx" />
      </files>
    </defaultDocument>
</system.webServer>

image path problem with routing in website

When we are applying routing with parameters in asp.net 3.5 then images are not displayed due to wrong path of images.

So we have to change the code for assiging image path in following way.

In aspx page

<img src="images/icon_first.gif" alt="" /> is replaced by <img src='<%= ResolveUrl("~/images/icon_first.gif") %>'  alt="" />

 
Same way, in javascript

 $get(obj).src ="images/button_qittop.jpg"; is replaced by $get(obj).src = '<%= ResolveUrl("~/images/button_qittop.jpg") %>';