Umbraco 7 single page application routing

假装没事ソ 提交于 2020-01-17 05:36:08

问题


I have a problem with my single page application made around Umbraco 7. I would like to redirect all requests to AngularJS instead of Umbraco, for that I have added the following urlrewrite to UrlRewriting.config:

<add name="SPA"
     virtualUrl="^~/(?![0-9]+/)([^\?]*?)$"
     rewriteUrlParameter="ExcludeFromClientQueryString"
     destinationUrl="~/"
     ignoreCase="true" />

But this redirects all responses to AngularJS, so now it not possible to open Umbraco at /umbraco. Does anyone know how to make a urlrewrite that redirects all responses to Angular except /umbraco?


回答1:


I've found that the solution was easier than it looked. Think regular expressions always is like that.The regular expression says: "From the start of the string after the base Url (~) exclude umbraco and ucommerce and uCommerce, the rest goes to base url.

Here's my solution:

<add name="Eventcatering"
     virtualUrl="^~/(?!umbraco|ucommerce|uCommerce)(.*)"
     rewriteUrlParameter="ExcludeFromClientQueryString"
     destinationUrl="~/"
     ignoreCase="true" />

I use the uCommerce package as well, which have some control API in /ucommerce, so these need to be excluded too.



来源:https://stackoverflow.com/questions/33688294/umbraco-7-single-page-application-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!