Is there a way to load the home page from outside the current application?

I am prototyping an environment where several applications run on the same server, but they all share the main page.

Can I load the main page from another application? In one of my applications, I have this code:

    protected override void OnPreInit(EventArgs e)
    {
        base.OnPreInit(e);
        this.MasterPageFile = "~/../MasterPages/Root.master";
    }

What this means is, set the home page to a file sitting outside of my current application. (Note the ".." after the tilde - so I go to the root of my current application and then expand the directory to find the main page.)

ASP is unhappy with the following:

The virtual path '/MasterPages/Root.master' maps to another application, which is not allowed.

I understand that it would be possible to emphasize the fact that there is no support class for it, but what if I have nothing in the code and I decided not to inherit my main page from anything - so the whole thing is contained in the file. master?

?

+3
3

, , , :

 protected override void OnPreInit(EventArgs e)
 {
        base.OnPreInit(e);
        this.MasterPageFile = "~/MasterPages/Root.master";
 }

, :

C:\Inetpub\Wwwroot\MasterPages
C:\Inetpub\Wwwroot\App1
c:\inetpub\wwwroot\App2

IIS :

\App1
\App1\MasterPages
\App2
\App2\MasterPages

+1

, .

+3

We have made our homepage very common. Each main page will use WebRequest to capture our shared hoseshoe html (or .aspx) page.

The hardest part of this approach is putting markers in a horseshoe. These markers will indicate what the application can replace and where to place its content.

0
source

Source: https://habr.com/ru/post/1779656/


All Articles