我正试图让blazor在IIS中托管的现有MVC应用程序中工作。我以为例
剃须刀页也有一个类似的例子。两者在IIS express和自托管中都能很好地工作,但当我尝试在IIS中使用它们时,它们失败了。
当托管在IIS中时,框架将注册到站点,而不是应用程序。当在chrome中打开时,控制台会出现以下错误:
blazor.server.js:1加载资源失败:服务器响应状态为503(服务不可用(favicon.ico:1加载资源失败:服务器响应状态为503(服务不可用(
我尝试将框架脚本引用从<script src="_framework/blazor.server.js"></script>
更改为<script src="~/_framework/blazor.server.js"></script>
。这解决了最初的错误,但blazor在下一步失败了:
[2020-03-05T09:46:07.566Z] Information: Normalizing '_blazor' to 'http://localhost/_blazor'.
_blazor/negotiate?negotiateVersion=1:1 Failed to load resource: the server responded with a status of 503 (Service Unavailable)
blazor.server.js:1 [2020-03-05T09:46:07.611Z] Error: Failed to complete negotiation with the server: Error: Service Unavailable
e.log @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
s @ blazor.server.js:1
Promise.then (async)
c @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
B @ blazor.server.js:1
e.getNegotiationResponse @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
B @ blazor.server.js:1
e.startInternal @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
B @ blazor.server.js:1
e.start @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
v @ blazor.server.js:1
e.startInternal @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
v @ blazor.server.js:1
e.startWithStateTransitions @ blazor.server.js:1
e.start @ blazor.server.js:1
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
r @ blazor.server.js:8
S @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
r @ blazor.server.js:8
E @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
n @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
Show 22 more frames
blazor.server.js:1 [2020-03-05T09:46:07.612Z] Error: Failed to start the connection: Error: Service Unavailable
e.log @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
s @ blazor.server.js:1
Promise.then (async)
c @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
B @ blazor.server.js:1
e.startInternal @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
B @ blazor.server.js:1
e.start @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
v @ blazor.server.js:1
e.startInternal @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
v @ blazor.server.js:1
e.startWithStateTransitions @ blazor.server.js:1
e.start @ blazor.server.js:1
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
r @ blazor.server.js:8
S @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
r @ blazor.server.js:8
E @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
n @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
Show 14 more frames
blazor.server.js:15 [2020-03-05T09:46:07.612Z] Error: Error: Service Unavailable
e.log @ blazor.server.js:15
C @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
s @ blazor.server.js:8
Promise.then (async)
c @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
r @ blazor.server.js:8
S @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
r @ blazor.server.js:8
E @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
n @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
blazor.server.js:1 Uncaught (in promise) Error: Cannot send data if the connection is not in the 'Connected' State.
at e.send (blazor.server.js:1)
at e.sendMessage (blazor.server.js:1)
at e.sendWithProtocol (blazor.server.js:1)
at blazor.server.js:1
at new Promise ()
at e.invoke (blazor.server.js:1)
at e. (blazor.server.js:15)
at blazor.server.js:15
at Object.next (blazor.server.js:15)
at blazor.server.js:15
e.send @ blazor.server.js:1
e.sendMessage @ blazor.server.js:1
e.sendWithProtocol @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
e.invoke @ blazor.server.js:1
(anonymous) @ blazor.server.js:15
(anonymous) @ blazor.server.js:15
(anonymous) @ blazor.server.js:15
(anonymous) @ blazor.server.js:15
r @ blazor.server.js:15
e.startCircuit @ blazor.server.js:15
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
a @ blazor.server.js:8
Promise.then (async)
c @ blazor.server.js:8
a @ blazor.server.js:8
Promise.then (async)
c @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
r @ blazor.server.js:8
E @ blazor.server.js:8
(anonymous) @ blazor.server.js:8
n @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
(anonymous) @ blazor.server.js:1
favicon.ico:1 Failed to load resource: the server responded with a status of 503 (Service Unavailable)
信号集线器似乎指向IIS中的根站点路径,而不是应用程序路径。
有人知道我该怎么解决吗?要重新创建问题,只需在此处下载源代码并设置指向IIS 的调试配置
感谢
Paul
感谢来自mars的agua的评论,解决方案是将以下标签添加到_layout.cshtml 的头部
例如
<head>
<meta charset="utf-8" />
<base href="~/" />