Javascript C#MVC5,RouteJs返回HTML而不是JS

Javascript C#MVC5,RouteJs返回HTML而不是JS,javascript,c#,asp.net-mvc-5,scriptresource.axd,Javascript,C#,Asp.net Mvc 5,Scriptresource.axd,我通过NuGet安装了适用于MVC 5的RouteJS,并遵循了安装说明,但在尝试加载时返回了_Layout.cshtml的内容和状态200 我正在运行MVC5、C#和IIS Express 8。我尝试了在其GitHub/NuGet网站上找到的Web.config的新变体。如果我使用区域,是否需要其他配置 #_Layout.cshtml #This works <script src="@RouteJs.RouteJsHandler.HandlerUrl"></script&g

我通过NuGet安装了适用于MVC 5的RouteJS,并遵循了安装说明,但在尝试加载
时返回了_Layout.cshtml的内容和状态200

我正在运行MVC5、C#和IIS Express 8。我尝试了在其GitHub/NuGet网站上找到的Web.config的新变体。如果我使用区域,是否需要其他配置

#_Layout.cshtml
#This works
<script src="@RouteJs.RouteJsHandler.HandlerUrl"></script>

#Web.config
<configSections>
    <section name="routeJs" type="RouteJs.RouteJsConfigurationSection, RouteJs" />
</configSections>

#This section by itself will break the application.
#Added the 'validation' line to system.webServer to prevent an error
#I've tried running RouteJS with and without this section.
<system.web>
    <httpHandlers>
        <add verb="GET" path="routejs.axd" type="RouteJs.RouteJsHandler, RouteJs" />
    </httpHandlers>
</system.web>

<system.webServer>
    <handlers>
        <validation validateIntegratedModeConfiguration="false"/>
        <add name="RouteJs" verb="GET" path="routejs.axd" type="RouteJs.RouteJsHandler, RouteJs" />
    </handlers>
</system.webServer>

<routeJs exposeAllRoutes="true" />

#RegisterRoutes
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
#_Layout.cshtml
#这很有效
#Web.config
#此部分本身将中断应用程序。
#将“验证”行添加到system.webServer以防止出现错误
#我试过在有和没有这个部分的情况下运行RouteJS。
#登记孔
routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);

为了添加路线,您必须为该区域声明此类代码:

public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Admin";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new { action = "Index", id = UrlParameter.Optional }
            );
        }
    }

我有MVC的区域设置。我不知道RouteJS是否需要额外的配置,因为我正在使用区域。你能尝试使用没有区域的RouteJS吗?当我创建一个没有区域的默认MVC应用程序时,RouteJS工作正常。我将继续使用这个应用程序,并查看它何时中断。RouteJs不起作用,因为我有一个url为“{*url}”的context.MapRoute,因为我正在构建一个单页应用程序。你知道有没有可能在routejs.axd异常的情况下使用{*url}?你可以在global.asax中捕获未修补的异常。如果你愿意,看看这个,它可能会帮助你。。。