Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
982 views
in Technique[技术] by (71.8m points)

asp.net - Configure IIS server to work with Aurelia framework and push state

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.

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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...