MVC迷你探查器包括不尊重程序的路径路径、程序、MVC

2023-09-07 14:21:03 作者:酒断人情思

我已经得到了MVC迷你探查器设置为描述其项目页面和包括事实上正在写在页面上。

I've got the MVC Mini Profiler set up as described on its project page, and the includes are indeed being written on the page.

但问题是,我的应用程序坐镇的http://本地主机:8080 /网络,并写入由监视标记包括如下所示:

Problem is, my application sits at http://localhost:8080/web, and the markup written by the profiler includes looks like this:

<link rel="stylesheet/less" type="text/css" href="/mini-profiler-includes.less?v=2.0.4177.17902">
<script type="text/javascript" src="/mini-profiler-includes.js?v=2.0.4177.17902"></script>
<script type="text/javascript"> jQuery(function() { MiniProfiler.init({ id:'fb4dc30e-c1aa-4be6-902c-ef2812dd1fe2', renderDirection:'left' }); } ); </script>

这些所有的课程给予404错误,但如果我浏览到 /web/mini-profiler-includes.less?,它加载的罚款。

These all of course give 404 errors, but if I navigate to /web/mini-profiler-includes.less?, it loads fine.

这将创建一个字符串的源代码可以发现here:

The source that creates that string can be found here:

// MiniProfilerHandler.cs
/// <summary>
/// Understands how to route and respond to MiniProfiler UI urls.
/// </summary>

public class MiniProfilerHandler : IRouteHandler, IHttpHandler
{
    internal static HtmlString RenderIncludes(MiniProfiler profiler, RenderPosition? position = null, bool showTrivial = false, bool showTimeWithChildren = false)
    {
        const string format =
            @"<link rel=""stylesheet/less"" type=""text/css"" href=""{0}mini-profiler-includes.less?v={1}"">
            <script type=""text/javascript"" src=""{0}mini-profiler-includes.js?v={1}""></script>
            <script type=""text/javascript""> jQuery(function() {{ MiniProfiler.init({{ id:'{2}', path:'{0}', renderDirection:'{3}', showTrivial: {4}, showChildrenTime: {5} }}); }} ); </script>";

        var pos = position ?? (MiniProfiler.Settings.RenderPopupButtonOnRight ? RenderPosition.Right : RenderPosition.Left);

        var result = profiler == null ? "" : string.Format(format,
                                                       EnsureEndingSlash(HttpContext.Current.Request.ApplicationPath),
                                                       MiniProfiler.Settings.Version,
                                                       profiler.Id,
                                                       pos.ToString().ToLower(),
                                                       showTrivial ? "true" : "false",
                                                       showTimeWithChildren ? "true" : "false");

        return new HtmlString(result);
    }

    // rest of the code
}

为什么不Request.ApplicationPath回到我的应用程序的路径?难道我做错了什么,或者我应该对MVC-迷你分析器页上的文件的问题?

Why isn't Request.ApplicationPath returning my application's path? Am I doing something wrong, or should I file an issue on the mvc-mini-profiler page?

编辑:为了使事情更离奇,我穿上了 MiniProfiler.RenderIncludes断点()通话,并检查什么样的价值 HttpContext.Current.Request.ApplicationPath 在那一刻,它是/网络!很神秘。

To make things even weirder, I put a breakpoint on the MiniProfiler.RenderIncludes() call, and checked what the value of HttpContext.Current.Request.ApplicationPath was at that moment, and it was "/web"! Very mysterious.

编辑2 :看起来他们可能已经(2小时前:))增加了对最新版本的虚拟路径的支持,和的NuGet包(这是我安装了),不完全最新。调查......

EDIT 2: Looks like they may have added support for virtual paths in the latest version (2 hours ago :)), and the NuGet package (which is how I installed it) is not completely up to date. Investigating...

推荐答案

拉最新的源代码(这个承诺是最近在这篇文章的时间),建设项目,抓住了DLL和引用,而不是使用项目的NuGet包,解决了这一问题。

Pulling the latest source (this commit being the most recent at time of this post), building the project, grabbing the DLL and referencing that instead of using the project's NuGet package fixed the problem.

修改:截至目前,该的NuGet包现在是最新的最新的提交,所以的NuGet远

EDIT: As of right now, the NuGet package is now up to date with the latest commit, so NuGet away!