1

I developed a small Angular app with WebApi, it works fine, and then here I’m turning my app around and showing it to someone, and this one doesn’t work anymore when I haven’t touched anything.

Here is the error in question:

ERROR

There is my index.schtml :

@inherits System.Web.Mvc.WebViewPage

@{
    ViewBag.Title = "Index";
}

<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>TestExamenAngular</title>
    <base href="/">

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons"
          rel="stylesheet">

    <link href="https://fonts.googleapis.com/css?family=Montserrat:300,700" rel="stylesheet">

    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- Optional theme -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
    <app-root></app-root>
    <script type="text/javascript" src="Scripts/angular/runtime.js"></script>
    <script type="text/javascript" src="Scripts/angular/polyfills.js"></script>
    <script type="text/javascript" src="Scripts/angular/styles.js"></script>
    <script type="text/javascript" src="Scripts/angular/vendor.js"></script>
    <script type="text/javascript" src="Scripts/angular/main.js"></script>
</body>
</html>

There is my global.asax :

namespace examenASPGENICQFlorian
{
    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);
            RegisterRoute(RouteTable.Routes);
        }

        private static void RegisterRoute(RouteCollection routes)
        {
            routes.MapRoute("catchAll", "{*catchAll}", new { controller = "Index", action = "Index" });
        }
    }

}

Thank in advance ;)

1
  • Change controller = "Index" to controller = "Home" Commented Jan 7, 2019 at 0:18

1 Answer 1

1

Your Routing has problem

routes.MapRoute("catchAll", "{*catchAll}", new { controller = "Index", action = "Index" })

Change it to

routes.MapRoute("catchAll", "{*catchAll}", new { controller = "Home", action = "Index" })

PS: I believe that you are using default template so your main controller is most probably HomeController thus I changed controller = "Home"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.