0

I have an MCV controller method which can load a total of 3 separate views, two of which are error pages just containing some static html.

    public ActionResult Index(string c)
    {
        try
        {
            var model = new HG.EnterpriseTools.Types.CodeContainer();
            if (string.IsNullOrWhiteSpace(c))
                return InvalidLink();
            model = HG.EnterpriseTools.CareNotifyCodeManager.ValidateCode(c);
            if (model.IsExpired)
            {
                return ExpiredLink();
            }
            if (!model.IsValid || model.PatientID == -1)
            {
                return InvalidLink();
            }
            else
            {
                return View();
            }
        }
        catch (Exception ex)
        {
            Logger.Error("fooController Index :: Error ::" + ex.Message);
        }

        return InvalidLink();            
    }

I have an Index.cshtml which only contains <div ng-view></div> and get's loaded in through the RenderBody() like any standard MVC page. Once the Index page loads I want all other routing to be handled by Angular using ngRoute. Here is a small example of what my routeProvider configuration.

careNotify.config(function ($routeProvider) {
    $routeProvider.when('/', {
        controller: 'MainController',
        templateUrl: 'Views/splash.html'
    }).when('/login', {
        controller: 'loginController',
        templateUrl: 'Views/Account/login.html'
    })
});

Yet when the index page loads and successfully attempts to load the default route as expected it fails with a 500 error. If instead I try to change the templateUrl path to ../Views/splash.html then I just get a 404. Any guidance? I'm still trying to wrap my head around mixing Angular and MVC with out needing to make a controller for each view and convert everything to .cshtml pages.

4
  • Can you show any message of the 500 error? Commented Mar 24, 2016 at 2:46
  • @JoelRamosMichaliszen this is about the best I can do from my log file 2016-03-23 22:49:17,544 HG.Models.Helpers.Logger - Server Last Exception from Global.asax :: System.Web.HttpException (0x80004005): Path '/HG.CareNotifyBridge/Views/splash.html' was not found. at System.Web.HttpNotFoundHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) Commented Mar 24, 2016 at 2:50
  • Possible duplicate of Use .Net MVC to only load index page and Angular for all other routes Commented Mar 24, 2016 at 2:55
  • Using $locationProvider.html5Mode(true) is actually only causing more problems for me. I will edit the question to reduce confussion. Commented Mar 24, 2016 at 2:56

0

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.