Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 服务器上的角度链接断开_Javascript_Angularjs_Iis_Visual Studio 2015_Html5mode - Fatal编程技术网

Javascript 服务器上的角度链接断开

Javascript 服务器上的角度链接断开,javascript,angularjs,iis,visual-studio-2015,html5mode,Javascript,Angularjs,Iis,Visual Studio 2015,Html5mode,我们正在处理类似的情况 我们处于HTML5模式,因此需要重写以修复URL。问题是,适用于已部署应用程序的解决方案在开发期间在Visual Studio中不起作用 我们针对已部署应用程序的解决方案通过将以下内容放在web.config中工作: <rewrite> <rules> <rule name="AngularJS Routes" stopProcessing="true"> <match url=".*" />

我们正在处理类似的情况 我们处于HTML5模式,因此需要重写以修复URL。问题是,适用于已部署应用程序的解决方案在开发期间在Visual Studio中不起作用

我们针对已部署应用程序的解决方案通过将以下内容放在web.config中工作:

<rewrite>
  <rules>
    <rule name="AngularJS Routes" stopProcessing="true">
      <match url=".*" />
      <conditions logicalGrouping="MatchAll">

        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_URI}" pattern="(api)" negate="true" />
        <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />

      </conditions>
      <action type="Rewrite" url="/myAppName/" />
    </rule>
  </rules>
</rewrite>

部署的应用程序不会将“myAppName”放在url中。为什么会这样

第二个问题是,在我们的Visual Studio开发环境中,
破坏了应用程序。这会使应用程序在输出中生成一个无穷无尽的错误字符串,如下所示:

SourceMap http://localhost:40288/app.module.js.map read failed: Unexpected character encountered while parsing value: <. Path '', line 4, position 1..SourceMap http://localhost:40288/app.core.module.js.map read failed: Unexpected character encountered while parsing value: <. Path '', line 4, position 1..SourceMap http://localhost:40288/app.config.js.map read failed: Unexpected character encountered while parsing value: <. Path '', line 4, position 1..

Exception was thrown at line 1247, column 4 in eval code
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 1265, column 4 in eval code
0x800a139e - JavaScript runtime error: SyntaxError

SourceMaphttp://localhost:40288/app.module.js.map 读取失败:解析值时遇到意外字符:如果为
指令创建绝对URL,它应该可以工作

例如,使用
部分中名为“baseLink”的
asp:Literal

Option Infer On

Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
    Dim baseUrl = Request.Url.GetLeftPart(UriPartial.Authority) & VirtualPathUtility.ToAbsolute("~/") & "myAppName/"
    baseLink.Text = $"<base href=""{baseUrl}"">"
End Sub
选项推断打开
受保护的子页_Init(发送方作为对象,e作为System.EventArgs)处理Me.Init
Dim baseUrl=Request.Url.GetLeftPart(UriPartial.Authority)和VirtualPath实用性.ToAbsolute(“~/”)&“myAppName/”
baseLink.Text=$“”
端接头

(我只是在最后加上了
&“myAppName/”
——我不在一台可以确认它是否应该使用
…来解决(“~/myAppName/”)
)的计算机上。)

我们尝试过,但它在本地对上面提到的所有异常产生了相同的问题。您是否输入了呈现的基本URL以确保其正确性?我们从这里看不到它。您建议的代码呈现为“”,这是正确的。但“/myAppName/”也会如此。这两种情况都会导致应用程序产生上述异常,并且页面永远不会呈现。它只是无限地产生这些异常。如果我将base更改为“/”本地一切正常,但在服务器上出现故障。啊,您可能会发现在本地使用IIS进行开发更容易。@jlembke我从“:40288”中假设您正在使用IIS Express进行开发,其优点是不需要以管理员身份运行VS。但是我使用IIS是因为(a)我可以,并且(b)这就是我要部署到的环境。啊哈!我刚刚发现“如果您的代码引用根级别的资源,例如…而没有指定它们位于项目根级别,那么当您在Visual Studio中进行测试时,应用程序可能会正常工作,但当您在生产环境中将其部署到IIS时,应用程序可能会失败。”
SourceMap http://localhost:40288/app.module.js.map read failed: Unexpected character encountered while parsing value: <. Path '', line 4, position 1..SourceMap http://localhost:40288/app.core.module.js.map read failed: Unexpected character encountered while parsing value: <. Path '', line 4, position 1..SourceMap http://localhost:40288/app.config.js.map read failed: Unexpected character encountered while parsing value: <. Path '', line 4, position 1..

Exception was thrown at line 1247, column 4 in eval code
0x800a139e - JavaScript runtime error: SyntaxError
Exception was thrown at line 1265, column 4 in eval code
0x800a139e - JavaScript runtime error: SyntaxError
Option Infer On

Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
    Dim baseUrl = Request.Url.GetLeftPart(UriPartial.Authority) & VirtualPathUtility.ToAbsolute("~/") & "myAppName/"
    baseLink.Text = $"<base href=""{baseUrl}"">"
End Sub