相关疑难解决方法(0)

MvcMiniProfiler结果请求在Asp.Net MVC应用程序中提供404

我试图在我的Asp.Net MVC应用程序中使用MvcMiniProfiler.我安装了最新的NuGet包,并从wiki页面添加到所有的代码Application_BeginRequest(),Application_AuthenticateRequest()并在我的观点.

加载页面后,所有迷你探查器的javascript文件都被包含在内并从服务器上正确下载,但当它尝试获取结果时Chrome显示:

GET http://localhost:59269/mini-profiler-results?id=59924d7f-98ba-40fe-9c4a-6a163f7c9b08&popup=1 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)

我认为这是由于没有设置MVC的路由允许/mini-profiler-results但是我找不到办法做到这一点.查看Google代码页,他们Global.asax.cs的示例应用程序的文件经历了多次更改,一次使用MvcMiniProfiler.MiniProfiler.RegisterRoutes(),第二次使用MvcMiniProfiler.MiniProfiler.Init(),第三种样式不执行任何操作.前面提到的两个函数不存在,所以我假设它们已被逐步淘汰.

在这一点上,我不确定如何修复此错误并在我的应用程序中使用分析器.有任何想法吗?


我的Global.Asax.cs文件如下所示:

public class Global : System.Web.HttpApplication
{
    protected void Application_BeginRequest()
    {
        MvcMiniProfiler.MiniProfiler.Start();
    }

    protected void Application_AuthenticateRequest(Object sender, EventArgs e)
    {
        // Only show profiling to admins
        if (!Roles.IsUserInRole(Constants.AdminRole))
            MvcMiniProfiler.MiniProfiler.Stop(discardResults: true);
    }

    protected void Application_Start(object sender, EventArgs e)
    {
        AreaRegistration.RegisterAllAreas();
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

        routes.MapRoute(
        "Default",
            // Route name
        "{controller}/{action}/{id}",
            // URL with …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc mvc-mini-profiler

12
推荐指数
1
解决办法
3736
查看次数

发布到 mini-profiler-results 给出 404,但仅在实时部署的站点上

页面加载后,我在从 MiniProfiler 获取 POST 结果时遇到了一些问题。

我试过 GET,它的工作原理。但是 POST 返回 404 错误,就好像它在寻找静态文件一样。

错误的镜头

任何有关我下一步可以尝试的帮助或提示将不胜感激。

这是我到目前为止所看到的:

这不是我的路线

GET/POST 问题会让我怀疑我的路线有问题 - 除了......

此问题仅发生在实时服务器上。在本地,路由运行良好。

可能是:runAllManagedModulesForAllRequest?

我读过的大部分内容都建议将其设置为 true。然而,我的问题似乎与此相矛盾。

runAllManagedModulesForAllRequest="true"设置为 true时出现问题,设置为 false 时修复。我想将它设置为 true ,因为我的知识不够丰富,无法从默认设置中更改它。

添加处理程序没有帮助

其他资源,比如这个(在 MP 主页的底部),建议将此行添加到 web.config 中的 system.webServer.handlers。

据我了解,即使 runAllManagedModulesForAllRequests 设置为 false,这也应该允许 MP 运行。对我来说,这两种方式都没有影响。

<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
Run Code Online (Sandbox Code Playgroud)

但是 Web.Config 中的处理程序部分是否相关?

我没有特别的理由认为这是...

我只是不完全理解它在做什么,想知道这是否可以解释本地版本和部署版本之间的差异。

<handlers>

  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
  <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
  <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
  <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." …
Run Code Online (Sandbox Code Playgroud)

web-config asp.net-mvc-routing http-status-code-404 mvc-mini-profiler

5
推荐指数
0
解决办法
408
查看次数