سؤال

I have followed a couple of guides on how to serve static content from a portable area but with no luck. I have two projects, a web project and a class library (which serves as my portable area). In my portable area (lets call it 'MyArea' for namesake) I have a Content folder with three folders inside that, Scripts, Styles, Images.

In the Scripts folder I have a simple js file as an embedded resource ('Hello.js'). My understanding is that the RegisterDefaultRoutes method called by RegisterArea creates routes for these which map to the following urls:

directory /Areas/AreaName/Content/Images maps to the URL /AreaName/Images

directory /Areas/AreaName/Content/Styles maps to URL /AreaName/Styles

directory /Areas/AreaName/Content/Scripts maps to URL /AreaName/Scripts

My layout view (_layout.cshtml) (which is in my web project which imports the MyArea project as a project reference) has the following in the head:

<script src="@Url.Content("~/MyArea/Scripts/Hello.js")" type="text/javascript"></script>

However, inspecting this returns a 404 so I must be doing something wrong

I have also followed the guides below with no luck

http://geekswithblogs.net/michelotti/archive/2010/04/13/mvc-portable-areas-enhancement-ndash-embedded-resource-controller.aspx

http://groups.google.com/group/mvccontrib-discuss/browse_thread/thread/b5f9c77f3a7523ff

What am I doing wrong?

Thanks very much.

هل كانت مفيدة؟

المحلول

Ok... so it was me doing something silly. I didn't follow the proper naming conventions, my Content folder was located in:

Project -> Content

Whereas it should have been in

Project -> {areaname} -> Content

(i.e. Project -> MyArea -> Content)

It works now, Thanks

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top