简体   繁体   English

一起使用ELMAH和URLRewritingNet

[英]Using ELMAH and URLRewritingNet Together

I have ELMAH setup on my production server and it has done a fantastic job of letting me know about any niggles - as well as any creative SQL injection! 我在生产服务器上安装了ELMAH,它做得非常好,可以让我知道任何麻烦-以及任何创造性的SQL注入!

I've decided to introduce URl Rewriting and went for http://www.urlrewriting.net/ in the end. 我决定介绍URl Rewriting,最后选择了http://www.urlrewriting.net/ It was nice and easy to setup and it's doing exactly what I want with the customer-facing site. 它非常好且易于设置,并且完全按照我想要的面向客户的网站进行。

The problem is ELMAH. 问题是ELMAH。 Because I've set the urlrewritingnet node in my config like so: 因为我已经在我的配置中设置了urlrewritingnet节点,如下所示:

<urlrewritingnet
  rewriteOnlyVirtualUrls="true"
  contextItemsPrefix="QueryString"
  defaultPage = "default.aspx"
  defaultProvider="RegEx"
  xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >

...ELMAH likes to do this to it's axd links; ... ELMAH喜欢对它的axd链接执行此操作;

http://www.mydomain.com/elmah.axd/stylesheet/default.aspx

Does anyone have any idea how to either a) stop the re-writer following the .axd; 是否有人知道如何执行以下操作:a)在.axd之后停止重写器; or b) add rules to the re-writer to get ELMAH to work 或b)向重写器添加规则以使ELMAH正常工作

Any ideas? 有任何想法吗? I'm happy to hack about with the httpHandlers ... 我很高兴与httpHandlers一起httpHandlers ...

I had the same issue - urlrewritingnet messing up my elmah - but found an answer here: http://markmail.org/message/ctbh6ozzqpe4qn6j#query:+page:1+mid:ctbh6ozzqpe4qn6j+state:results 我遇到了同样的问题-urlrewritingnet弄乱了我的Elmah-但在这里找到了答案: http ://markmail.org/message/ctbh6ozzqpe4qn6j#query:+page:1+mid:ctbh6ozzqpe4qn6j+state:results

Basically set defaultPage to empty like this: 基本上将defaultPage设置为空,如下所示:

Before (shortened): 之前(缩短):

<urlrewritingnet defaultPage="default.aspx" ... >

After (shortened): 之后(缩短):

<urlrewritingnet defaultPage="" ... >

Now all css styles work for Elmah. 现在,所有css样式都适用于Elmah。

I came up with a simpler solution if others are interested. 如果其他人感兴趣,我想出了一个更简单的解决方案

I just modify the source code directly and add in some basic logic to ignore specific rewrite rules. 我只是直接修改源代码,并添加一些基本逻辑来忽略特定的重写规则。

I kind of solved this, but not in the way I wanted too. 我有点解决了这个问题,但不是我想要的那样。 For the reference of others, I will provide a breakdown of what I did and the resources; 供我参考,我将提供所做工作和资源的细分;

ELMAH: http://code.google.com/p/elmah/ URLRewritingNet: http://www.urlrewriting.net/149/en/home.html ELMAH: http : //code.google.com/p/elmah/ URLRewritingNet: http ://www.urlrewriting.net/149/en/home.html

This was really the only available option to me: http://csharpin.blogspot.com/2009/03/using-urlrewritingnet-and-elmah.html , but I had untold difficulty to get the code into my existing architecture without other adverse affects. 这确实是我唯一可用的选项: http : //csharpin.blogspot.com/2009/03/using-urlrewritingnet-and-elmah.html ,但是我在将代码导入现有体系结构而又没有其他不利影响方面遇到了巨大的困难影响。 I did try adding rules to the ExternalRewrite.config (URL Rewrite) to ignore *.axd, but that didn't pan out either. 我确实尝试将规则添加到ExternalRewrite.config(URL Rewrite)中以忽略* .axd,但这也没有成功。 I was getting all sorts of weird behaviour. 我得到了各种各样的怪异行为。

I then decided to use Health Monitoring: http://www.4guysfromrolla.com/articles/031407-1.aspx instead of ELMAH. 然后,我决定使用“健康监视”: http ://www.4guysfromrolla.com/articles/031407-1.aspx代替ELMAH。 Sorry ELMAH :( 抱歉ELMAH :(

Health Monitoring was a snip to setup and then all I had to do was solve the nasty postback problem on rewritten URLs; 运行状况监视是一个简单的设置,然后我要做的就是解决重写URL上令人讨厌的回发问题。

Health Monitoring web.config; 运行状况监视web.config;

<!--he-mon-->
    <healthMonitoring enabled="true">
      <eventMappings>
        <clear />
        <add name="All Errors" type="System.Web.Management.WebBaseErrorEvent" startEventCode="0" endEventCode="2147483647" />
      </eventMappings>
      <providers>
        <clear />
        <add connectionStringName="healthMonitoringConnectionString" maxEventDetailsLength="1073741823" buffer="false" name="SqlWebEventProvider" type="System.Web.Management.SqlWebEventProvider" />
        <add type="System.Web.Management.SimpleMailWebEventProvider" name="EmailWebEventProvider" from="xxx" to="yyy" bodyHeader="zzz" bodyFooter="000" buffer="false" />
      </providers>
      <rules>
        <clear />
        <add name="All Errors Default" eventName="All Errors" provider="SqlWebEventProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
        <add name="All Errors Default Email" eventName="All Errors" provider="EmailWebEventProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
      </rules>
    </healthMonitoring>
    <!--he-mon-->

Add the connection string to the connectionString node too. 也将连接字符串添加到connectionString节点。

To fix the rather nasty postback on URL rewritten strings, I tried ScottGu's suggestion; 为了解决URL重写字符串上相当讨厌的回发,我尝试了ScottGu的建议。 Handling ASP.NET PostBacks with URL Rewriting: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx , but I couldn't get that to work at all. 使用URL重写处理ASP.NET回发: http ://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx,但是我做不到让它工作。

Starting to really regret getting into URL Rewriting, I finally added this to the one problematic page I had; 开始真正后悔进入URL重写后,我终于将此添加到了我遇到的一个有问题的页面中; Me.Form.Action = Me.Request.RawUrl within the Page_Load and it worked a treat. Page_LoadMe.Form.Action = Me.Request.RawUrl起作用了。

I know this doesn't directly answer the question, but I hope it helps. 我知道这并不能直接回答问题,但希望对您有所帮助。 I hope someone finds my information at least somewhat useful. 我希望有人觉得我的信息至少有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM