Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am developing an application in Angular and ASP.NET MVC. I would like to keep some Angular partials and MVC partials in the same folder because they are logically related. For example:

  • /MyApp/Widgets/Image-config.html
  • /MyApp/Widgets/Image-designer.html
  • /MyApp/Widgets/Image.cshtml

I was able to make the Widgets folder used as a shared partial folder by adding this to Global.asax:

ViewEngines.Engines.Add(new RazorViewEngine
        {
            PartialViewLocationFormats = new string[]
            {
                "~/Widgets/{0}.cshtml",
                "~/Views/{1}/{0}.cshtml",
                "~/Views/Shared/{0}.cshtml"                    
            }
        });

And copying the web.config from the default Views folder.

However, now I get a 404 when Angular goes to get the .html templates. Is there any way to configure the Widgets folder such that it can both serve up static files and be a location for my server-side partial views?

share|improve this question
add comment

1 Answer

What I do is create controller methods and use partial views, so my angular views are .cshtml too. The url for your angular view is then the url for the controller action returning the partial view.

share|improve this answer
    
Hmm. It crossed my mind. I just figured static .html would serve up faster and with less overhead if it didn't need to involve loading up the controller and view engine. –  Daniel 3 hours ago
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.