ASP.NET MVC4 显示模式不加载 TypeScript 输出

ASP.NET MVC4 display modes not loading TypeScript output

本文关键字:加载 TypeScript 输出 模式 NET MVC4 显示 ASP      更新时间:2023-09-26

我有一个使用互联网模板创建的 ASP.NET MVC4应用程序。 在这个项目中,我在视图/共享文件夹中有两个布局文件,_Layout.chsmtl和_Layout.Mobile.cshtml。 在每个文件中,我都在加载从 TypeScript 编译的不同脚本。在_Layout.cshtml中,我有

<script src="@Url.Content("~/Scripts/app.js?43")" type="text/javascript"></script>

在_Layout.Mobile.cshtml中,

<script src="@Url.Content("~/Scripts/MobileApp.js?2")" type="text/javascript"></script>

应用程序.js和移动应用程序.js基于项目文件中的以下设置创建:

 <Target Name="BeforeBuild">
    <Exec Command="&quot;$(PROGRAMFILES)'Microsoft SDKs'TypeScript'0.8.0.0'tsc&quot; -out scripts'app.js scripts'app.ts -target ES5 @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" IgnoreExitCode="true" /> 
    <Exec Command="&quot;$(PROGRAMFILES)'Microsoft SDKs'TypeScript'0.8.0.0'tsc&quot; -out scripts'mobileapp.js scripts'mobileapp.ts  -target ES5 @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" IgnoreExitCode="true" />
  </Target>

应用程序在 Internet Explorer 9 中正常运行。 但是,当我在 Opera Mobile 中运行时,似乎没有加载 mobileapp.js,因为它只显示警报的构造函数没有被调用。 这是 MobileApp 的 TypeScript 代码.js。

 export class MobileApp extends AppBase {                                  
        constructor () { 
            super(null, null)                
              alert("mobile page loading ...?");
        }      
    }

每次刷新 Opera Mobile 上的索引页面时,我还会在应用程序日志中写入以下消息:

ERROR 2013-01-24 09:39:57,233 172979ms MvcApplication         Application_Error  - ASP.global_asax
System.Web.HttpException (0x80004005): File does not exist.
   at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response)
   at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context, String overrideVirtualPath)
   at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

有什么想法吗?

为了使构造函数运行,您必须实例化该类。例如:

var test = new MobileApp();