Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Proks 6 posts 100 karma points
    Aug 07, 2017 @ 08:24
    Martin Proks
    0

    [SOLVED] Umbraco with Angular as frontend

    [UPDATE]:

    For those who are trying to use Angular as frontend and Umbraco as a backend, just build an Angular app and upload it into the root folder for example. Setup the IndexController as I showed below. When you now open a page the site will work, but won't be able to find all the files like other js and css files. You have create a RewriteUrl. Example shown below.

    <rewrite>
      <rules>
        <rule name="test" enabled="true">
          <match url="^(?!umbraco)(.*(json|js|css|svg))" ignoreCase="false"/>
          <action type="Rewrite" url="/dist/{R:1}" appendQueryString="true" logRewrittenUrl="false"/>
          <conditions>
                            </conditions>
        </rule>
      </rules>
      <rewriteMaps>
        <rewriteMap name="{HTTP_HOST}"/>
      </rewriteMaps>
    </rewrite>
    

    Hey guys,

    I ran into a problem that I've got issues solving. I am using Umbraco as a backend engine and I would like to use Angular 4.x as my front-end. I want now Umbraco to load my Angular front-end. I've created an IndexController like this.

    public class IndexController : Controller
    {
        public ActionResult Index()
        {
            return new FilePathResult("~/Views/Index/index.html", "text/html");
        }
    }
    

    The problem is that Umbraco will not be able to load other js and css files because he's looking in the root directory. Is there some way to persuade the controller to use a specific directory, so he could load those files?

    Thank you.

    /Martin

Please Sign in or register to post replies

Write your reply to:

Draft