yaya2
yaya2

Reputation:

Is it possible to get a master page from my parent Virtual directory/ application/

I have a virtual directory inside of my main virtual directory in IIS.

can i reference the parent application and reference its master page? If yes, how?

Upvotes: 1

Views: 1611

Answers (3)

Moxen
Moxen

Reputation: 233

Much to my surprise this is possible-- if you make a virtual directory which points back to your master page folder in the parent application. E.g.:

  • /parentApp - root directory for the parent
  • /parentApp/Master - master pages for the parent
  • /parentApp/childApp - child application
  • /parentApp/childApp/Master - a virtual directory pointing to /parentApp/Master

With this setup, this can work in your child web.config:

<pages masterPageFile="~/Master/Default.master">

I assume that references to other master pages in the @Page directive will work, but I have not tried it.

Upvotes: 1

Richard Szalay
Richard Szalay

Reputation: 84784

For all intents and purposes, no it's not possible. ASP.NET will not execute an ASPX/ASCX/MASTER outside of it's AppDomain. I recommend you go down a different route with your solution (compiled into a common dll, for example)

Edit: One potential question to ask is whether you need a virtual directory or not. What is it that made you chose to separate them in the first place?

Beyond that, you could possibly fake it by writing your own virtual path provider, but that would lead to a world of hurt (with the base classes not being compiled, etc).

I recommend you go for the simplest solution possible.

Upvotes: 2

Gordon Bell
Gordon Bell

Reputation: 13633

No, I don't think it's possible due to security concerns.

Upvotes: 0

Related Questions