2011-10-14 36 views
13

我在一個非常簡單的項目工作可愛添加Mini Profiler通過NuGet,雖然,這是一個大的和現有的項目,當然是我得到了一些問題它:(迷你探查不會呈現腳本

它在源代碼中編寫正確的腳本標籤爲

<link rel="stylesheet" type="text/css" href="/mini-profiler-includes.css?v=1.9.0.0"> 
<script type="text/javascript">  
    if (!window.jQuery) document.write(unescape("%3Cscript src='/mini-profiler-jquery.1.6.2.js' type='text/javascript'%3E%3C/script%3E"));  
    if (!window.jQuery || !window.jQuery.tmpl) document.write(unescape("%3Cscript src='/mini-profiler-jquery.tmpl.beta1.js' type='text/javascript'%3E%3C/script%3E"));  
</script>  
<script type="text/javascript" src="/mini-profiler-includes.js?v=1.9.0.0"></script>  
<script type="text/javascript">  
    jQuery(function() {  
     MiniProfiler.init({  
      ids: ["e48fcf61-41b0-42e8-935a-fbb1965fc780","870a92db-89bc-4b28-a410-9064d6e578df","30881949-bfdb-4e3a-9ea5-6d4b73c28c1d","6bca31b8-69d9-48eb-b86e-032f4d75f646","df16838d-b569-47d0-93e6-259c03322394"],  
      path: '/',  
      version: '1.9.0.0',  
      renderPosition: 'left',  
      showTrivial: false,  
      showChildrenTime: false,  
      maxTracesToShow: 15  
     });  
    });  
</script> 

但是當我嘗試打開任何文件,我得到一個HTTP 404

enter image description here

我證實沒有App_StartMiniProfiler.cs並添加一個破發點出現,代碼運行,我甚至增加

#region Mini Profiler 

protected void Application_BeginRequest() 
{ 
    if (Request.IsLocal) 
    { 
     MiniProfiler.Start(); 
    } 
} 
protected void Application_EndRequest() 
{ 
    MiniProfiler.Stop(); 
} 

#endregion 

global.asax文件...

Is there something obviously that I'm missing?

+0

這是一個MVC網站嗎? – scottm

+0

是的,對不起,錯過了標籤 – balexandre

+0

我的猜測是iis問題,你運行的是哪個版本? –

回答

11

這是IIS的某些配置的已知問題。

解決方法是確保UrlRoutingModule處理所有的小輪廓儀包括在web.config

<system.webServer> 
    <handlers> 
     <add name="UrlRoutingModule1" path="mini-profiler*.js" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" /> 
     <add name="UrlRoutingModule2" path="mini-profiler*.css" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" /> 
     <add name="UrlRoutingModule3" path="mini-profiler*.tmpl" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" /> 
    </handlers> 
</system.webServer> 

有關於這個問題2張開放門票的那一刻:

在未來的版本中,爲了避免這個問題,我們可能會爲我們提供包括extensionless

+0

在IIS Express中運行時,我看到「Uncaught ReferenceError:」MiniProfiler「未定義」Chrome中的錯誤。這個錯誤導致我們所有其他文檔就緒腳本無法運行,從而破壞了我們的整個網站。原來這是問題。 –

+0

這解決了我使用IIS7和默認配置的問題。謝謝!請務必檢查MiniProfiler主頁上的「故障排除」部分。 –

+4

在MVC4(Internet模板)中,我一直在收到require.js的404,直到我在部分添加。如果你不想rullAllManagedModulesForAllRequests引用這個線程http://stackoverflow.com/questions/10212725/miniprofiler-cannot-find-jquery替代解決方案,我測試了兩個,他們工作正常。 – sumitkm