具有.NET 4.0的UrlRewriter.NET无法正常工作 [英] UrlRewriter.NET with .NET 4.0 not working

查看:104
本文介绍了具有.NET 4.0的UrlRewriter.NET无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装了UrlRewriter.NET的Web项目,并且在.NET 3.5本地上可以正常工作。

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

然后我将其升级到.NET 4.0,并且继续在我的本地PC上运行Visual Studio 2010。

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

当我将此.NET 4.0项目移动到服务器时,URL重写停止工作。

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

这是我的web.config(此处出于可读性而压缩)

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>

放在服务器上时,它只会返回404。

When put on the server it just returns a 404.

有趣的发现。如果我创建一个名为/ Neat-Url的目录,则URL重写将再次开始,并重定向到/Ugly-Url.aspx?id=1

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

注意:是的,我意识到.NET 4.0拥有自己的url重写功能,并且我还拥有与UrlRewriter一起使用的现有代码。

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]:好的,所以我确定了其他方法。除非文件或目录实际存在,否则URL重写器将无法工作。

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

例如。如果我想将/ Directory1重定向到/Directory1.aspx,则/ Directory1必须存在,那么一切正常。

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

如果我要将/File1.aspx重定向到/ File2.aspx也可以使用,但是File1.aspx必须存在于文件系统上。

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

否则,我将继续获取404。这似乎可以通过.NET解决,并且需要与web.config一样,将File1.aspx调用传递给运行时并获得asp.net404。调用目录仅获得Web主机404。

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.

[更新2]:我删除了

[UPDATE 2]: I removed the

<httpModules> 

部分,然后添加

<identity impersonate="false"/>

然后还更改了validateIntegratedModeConfiguration = true。仍然是相同的问题,但至少现在可以在集成模式下进行验证。

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

[UPDATE 3]:我现在正在尝试ManagedFusion,但仍然遇到错误,但看起来更像是我的配置错误而不是服务器支持。我提出了另一个问题 ManagedFusion网址重写不起作用

[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.

希望能解决我的问题。

推荐答案

更改将模块重写到 Url重写模块。我在Godaddy遇到了同样的问题,所以改变就可以解决我的问题。

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

这篇关于具有.NET 4.0的UrlRewriter.NET无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆