配置 IIS 服务器以使用 Aurelia 框架和推送状态 [英] Configure IIS server to work with Aurelia framework and push state

查看:36
本文介绍了配置 IIS 服务器以使用 Aurelia 框架和推送状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 这个 repo 开始创建了一个基本的 aurelia 应用程序,我试图摆脱 URL 栏中的 #(主题标签).

I have created a basic aurelia app starting from this repo and I was trying to get rid of the # (hashtag) in the URL bar.

我有 2 个项目,一个在一台机器上运行 WebApi,一个在另一台机器上运行一个空的 web 项目(不是 MVC).在官方文档网站上,它只说明了如何配置路由,但我的项目不是面向 MVC 的.

I have 2 projects, one running WebApi on a machine and one running an empty web project (not MVC) on another machine. On the official documentation website it only says how to configure your routes but my project is not MVC oriented.

如何从 Web.config 配置 IIS 服务器,当我访问 http://localhost/home 时,它应该启动 aurelia 框架而不是 404 not found 页面?

How can I configure the IIS server from Web.config in a sense that when I access http://localhost/home it should start the aurelia framework rather than the 404 not found page?

推荐答案

我正在使用 Azure,它需要一个 web.config 来正确处理非哈希路由,它只是将所有路由重定向到包含 aurelia 的 index.html应用程序.没有它(或类似的技术),它会产生 404.

I'm using the Azure which needed a web.config to handle non hash routing correctly, it just redirects all routes into the index.html which contains the aurelia app. Without it (or a similar technique) it was giving 404s.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.webServer>
     <rewrite>
             <rules>
                 <remove name="redirect all requests" />
                 <rule name="redirect all requests" stopProcessing="true">
                     <match url="^(.*)$" ignoreCase="false" />
                     <conditions logicalGrouping="MatchAll">
                         <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
                     </conditions>
                     <action type="Rewrite" url="index.html" appendQueryString="true" />
                 </rule>
             </rules>
         </rewrite>
    </system.webServer>
</configuration>

希望这会有所帮助.

这篇关于配置 IIS 服务器以使用 Aurelia 框架和推送状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆