I'm creating an ASP.NET MVC solution, and inside I had 2 MVC Website projects.
I'm interested in creating a 3rd project called "Shared", where I can reference the shared views/content between the two sites so I have only one place to edit them.
How can I reference a Masterview's location if it is in a different project?
So, normally at the top of a view I would reference a Masterview like so:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Tabbed.Master" Inherits="System.Web.Mvc.ViewPage<WebUI.ViewModels.Admin.EditProfileViewModel>" %>
However,
Now, that "Tabbed.Master" isn't in the local project, it is in a difference project in the solution. I've created a reference to the project but I don't know how to reference Tabbed.Master from WebUI.Site1 to WebUI.Shared?
Something like:
<%@ Page Title="" Language="C#" MasterPageFile="WebUI.Shared.Views.Tabbed.Master" Inherits="System.Web.Mvc.ViewPage<WebUI.ViewModels.Admin.EditProfileViewModel>" %>
Doesn't work.
How can I reference the location of things like masterviews, css files, images across projects like that?
Due to the nature of MasterViews, you need to find a filebased solution. The virtual path is one way to do it, but I think you will get in trouble at some point: How do you handle the file references when you use the internal Visual Studio web server?
And think of the pain you suffer when this virtual path is missing in IIS.
Visual Studio let you link to files from other projects. Those files will be copied over at compile time:
Right-click in Solution Explorer -> Add existing item... -> select files -> Add As Link
Personally, I don't care for this feature. But it seems to do what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With