Click to See Complete Forum and Search --> : ASP.NET Master Page Problem with Virtual Directory Alias


kwilliams
03-02-2011, 01:47 PM
To make it easier for users to get to a section of our site, we created a virtual directory alias which redirects the user to a specific web page. If there's no virtual directory for http://www.mysite.com/subdirectory/webpage.aspx, then that Master Page reference works fine. But once I created a virtual directory and attempted to get to that same page by typing the path to the virtual directory (http://www.mysite.com/subdirectory), I received this error message relating to the web page trying to access our site's Master Page, which is located in the root of the site:

Server Error in '/subdirectory' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The file '/subdirectory/MasterPage.master' does not exist.

Source Error:

Line 1: <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" EnableSessionState="true" EnableViewState="false" Title="Web Page" %>

Source File: /subdirectory/webpage.aspx Line: 1

I've tried changing the "~/MasterPage.master" reference to "./MasterPage.master" (one period), "../MasterPage.master" (two periods), "/MasterPage.master" (no tilde before slash), and "MasterPage.master" (just the file name) to no avail! Does anyone here know how I can fix this?

These are two sites that contain steps on what we did:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/33e0a51a-5f8a-40f2-9923-cdd604e1a812.mspx?mfr=true (under "Virtual Directories")
http://www.beansoftware.com/ASP.NET-Tutorials/Set-Up-IIS-ASP.NET.aspx (under "How to create the virtual directory on the web server")

Ribeyed
03-13-2011, 07:27 AM
Hi kwilliams,

Have you tried attching your master page at the application level? You can defind the master page in your web.config file:


<pages masterPageFile="MySite.Master" />



This would specify that all ASP.NET pages in the application bind to your master page.


source of code: http://msdn.microsoft.com/en-us/library/wtxbf3hh(v=VS.80).aspx#Y1094


regards

Ribs

kwilliams
03-22-2011, 04:33 PM
Thanks for the reply Ribeyed.

I tried your suggestion, and received the following error message:
The relative virtual path 'MasterPage.master' is not allowed here.

So then I changed "MasterPage.master" to ~/MasterPage.master", and received the same error as my first post:
The file '~/MasterPage.master' does not exist.

I also tried creating a web.config file within the virtual directory with this data, and received the exact same errors.

The good thing is that the virtual directory is not being attached to the Master Page's path as before, but it's still not finding it.

Do you have any other suggestions?