2

I have a web project that had UrlRewriter.NET installed and working fine on .NET 3.5 locally.

I then upgraded it to .NET 4.0 and this continued to work on my local PC in Visual Studio 2010.

When I moved this .NET 4.0 project to my server the url rewriting stopped working.

Here is my web.config (condensed for readability here)

<?xml version="1.0"?>
<configuration> 
   <configSections>
      <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
   </configSections>

   <system.web>

   </system.web>
   <rewriter>
      <rewrite url="~/Neat-Url" to="~/Ugly-Url.aspx?id=1"/>
   </rewriter>
   <system.webServer>
       <validation validateIntegratedModeConfiguration="false"/>
       <modules runAllManagedModulesForAllRequests="true">
           <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule"/>
       </modules>
    </system.webServer>
</configuration>

When put on the server it just returns a 404.

Interesting discovery. If I create a directory called /Neat-Url, the url rewriting starts working again and redirects to /Ugly-Url.aspx?id=1

Note: Yes I realize that .NET 4.0 has it's own url rewriting and I also have existing code that works with UrlRewriter.

So am I doomed because it is a server configuration issue or is there a way I can work around it?

[UPDATE]: Ok so I have determined something else. The url rewriter won't work unless the file or directory actually exists.

For example. If I want to redirect /Directory1 to /Directory1.aspx, /Directory1 must exist, then it all works fine.

If I want to redirect /File1.aspx to /File2.aspx this also works but File1.aspx must exist on the file system.

Otherwise I continue to get a 404. This seems solvable via .NET and has something to do with the web.config as calling upon File1.aspx gets passed to the runtime and gets an asp.net 404. Calling a directory just gets a web host 404.

[UPDATE 2]: I removed the

<httpModules> 

section from my web config, then added

<identity impersonate="false"/>

Then also changed validateIntegratedModeConfiguration="true". Still the same problem but at least is validates in Integrated Mode now.

[UPDATE 3]: I am now trying ManagedFusion yet still running into errors, but it seems more like a configuration error on my part rather than server support. I raised another question ManagedFusion Url Rewriting not working.

Hopefully that will solve my problems.

Community
  • 1
  • 1
Adam
  • 16,089
  • 6
  • 66
  • 109
  • A question that hasn't been answered in 10 minutes on Stackflow. I must be in trouble :) – Adam Feb 03 '11 at 08:50
  • Why not just use the builtin rewriter provided by Microsoft? – leppie Feb 04 '11 at 05:07
  • I disagree with a random closing and down voting of this question. Yes it is 5 years old, but the problem still exists just on older technology. The Off-Topic flag on this question seems invalid as it can be reproduced and it was not due to a simple typographical error. The downvote also seems completely unjustified. – Adam Aug 20 '16 at 01:42
  • @AdamPedley, FYI: The [godaddy] tag is being burniated [meta](http://meta.stackoverflow.com/questions/331817/please-help-out-with-burninating-godaddy), that is why it has received attention- – Petter Friberg Aug 21 '16 at 23:29
  • thanks @PetterFriberg - that explains its attention. Happy with the tag going but disappointed at the actions being taken regarding pre-existing questions with valid problems and answers. – Adam Aug 21 '16 at 23:35
  • Yeah, try to re-formulate your questions (I have seen another one also), to not be so specific about godaddy (hence if possibile more general hosting), then step by the [SOCVR](http://chat.stackoverflow.com/rooms/41570/so-close-vote-reviewers) room, that are leading this effort, you can try and ping the close voters there (example rene), he will be happy to help you out. – Petter Friberg Aug 21 '16 at 23:39
  • thanks again @PetterFriberg - looking at the my Godaddy questions they were not Godaddy specific, hence i have reworked both of them to remove Godaddy references. It was IIS configuration that was the issue. And its probably good to remove any reference that I ever used Godaddy in the past :) – Adam Aug 21 '16 at 23:45

7 Answers7

3

What kind of application pool you are using? UrlRewrite does not work with Classic Application Pool for .NET 4.0, your application pool has to be configured for .NET 4.0 Pipeline mode only.

Akash Kava
  • 39,066
  • 20
  • 121
  • 167
  • It's using the integrated pipeline (not classic) – Adam Feb 04 '11 at 02:50
  • Switching from classic to pipeline caused UrlRewrite to kick in for me on Godaddy (.net4, iis7), when it wasn't previously playing ball. – Ted Mar 15 '13 at 00:46
1

You can use alternate rewriters that work with .net 4.0 and GoDaddy. Such as the Managed Fusion URL Rewriter and Reverse Proxy.

My guess is that some permission related to GoDaddys medium trust config is causing the inconsistencies you are seeing.

Nick Berardi
  • 54,393
  • 15
  • 113
  • 135
  • It seems like not all requests are been passed to the ASP.NET runtime which is why the URL rewrite doesn't work unless there is a directory or file there. – Adam Feb 03 '11 at 12:55
1

change rewrite module to Url Rewrite Module. I had same problem with Godaddy, so changing is solved my problem.

0

@gilly3 had the answer right! I've just tested it on my own system (IIS 8, .NET 4.5 framework)

Originally I had this in my web.config, which has been working for .NET framework 3.5 and below

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

so I changed it to below, and it works!

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
       <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
    </modules>
</system.webServer>
0

Actually what you want is this. Make sure this setting is false because otherwise after URL Rewriting rewrites the URL, the .NET application might re-route it back.

   <system.webServer>
       <modules runAllManagedModulesForAllRequests="true">
Ben H
  • 3,136
  • 3
  • 25
  • 34
0

It seems as though URL Rewriter.NET is not going to play nicely.

It is most likely due to the fact my application runs in a virtual directory.

I did manage to get Microsoft's URL rewriting working (not Url Routing as that also has issues with virtual directories).

So that is what I will use.

I think it is fair to say URLRewriter.NET has had it's day.

Adam
  • 16,089
  • 6
  • 66
  • 109
0

This answer got UrlRewriter to work on my GoDaddy account:

Can Intelligencia.UrlRewriter be made to work in IIS7?

The solution is to add this to your web.config:

<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <modules runAllManagedModulesForAllRequests="true">
    <add name="UrlRewriter" 
      type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
  </modules>
</system.webServer>
Community
  • 1
  • 1
gilly3
  • 87,962
  • 25
  • 144
  • 176