Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ASP.Net MVC4 Web API with AngularJS partial views (aka ng-include)

Is it possible to return '*.htm' files from the ASP.Net MVC4 Web API application?

I am trying to use AngularJs to manage the client side views and when I include the following commend on my page:

<div ng-controller="application.RootController">
    <div ng-switch="subview" >
        <div ng-switch-when="home" ng-include="'../Views/Angular/customer/overview.htm'"></div>
        <div ng-switch-when="admin" ng-include="'../Views/Angular/Admin/home.htm'"></div>
    </div>
</div>

I see that this is working as expected on the browser, but the ASP.Net is returning 404 page not found.

Also I am unable to physically browse any of the htm pages, so is there a special thing i need to do in ASP.Net MVC in terms of configuring the routing to return out the htm pages?

like image 614
Kiran Avatar asked Nov 13 '13 09:11

Kiran


1 Answers

Files in the ~/Views folder are not served directly. You should place your HTM pages somewhere else. For example you could have an ~/Angular folder.

like image 101
Darin Dimitrov Avatar answered Sep 22 '22 18:09

Darin Dimitrov