views:

313

answers:

2

hi i have implemented URL routing in asp.net 4.0 using following route.

    routes.MapPageRoute(
       "NewsDetails",               // Route name
       "news/{i}/{*n}",  // Route URL
       "~/newsdetails.aspx"      // Web page to handle route

    );

which gives me url like

http://www.mysie.com/news/1/this-is-test-news

Which is working in my localhost fine. but when i uploaded it on the server it gives

 Server Error

 404 - File or directory not found.
 The resource you are looking for might have been removed, had its name changed, or     is   temporarily unavailable.

if i try http://www.mysie.com/news/1/this-is-test-news.aspx then it displays page.

can anyone have same problem?

how can i set URL http://www.mysie.com/news/1/this-is-test-news to work on windows server 2008 ?

A: 

jus found solution from ron Jacobs at his blogpost System.Web.Routing RouteTable not working with IIS?

Config file Code for above answer:

 <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> 
  </system.webServer>
Pragnesh Patel
Can you add more detail on your answer for others. Just a summary. Was it a difference in IIS versions?
uriDium
A: 

To enable default asp.net 4.0 routing with IIS 7.5 :

  1. Make sure that you have installed the HTTP Redirection feature It can be done --> Control Panel --> Progams --> Turn off windows features --> World wide web Services --> Common HTTP Features --> HTTp Redirection
  2. Modify your web.config

    Version=2.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a"/>

  3. Create Routes in your global.asax file

Note: You have to set Application Pool to Asp.net 4.0 application pool , as routing is not working with Asp.net 4.0 Classic Application pool.

Hope this will help.

Pragnesh Patel