so this is driving me crazy...
I'm working on a website in Visual Studio 2015 (so from the start page: File>New>Web Site... NOT New Project>Web>ASP.NET Web Application) and things are going well when I use VS as the debugger/localshost.
Now, being cautious, I want to upload the site to a www.mysite.com/sandbox/ folder where I can test out some further items such as database access and the like (since the site is live, I don't want to replace it until I'm ready). But for some reason, all files (which worked fine through localhost) seem to point to "/" for the master pages and other items rather than "/sandbox/" ...
Is there any way that I can tell VS that the root is not where it thinks it is?
So far I've verified that this is purely something with the root location: I've cautiously created a different project (with file names that I can easily find & delete on the live server) to see if anything is wrong on the server, but they load fine if I keep the root in the files the same as the root on the server (in other words, if I uploaded my site to the root, the references would be ok). BTW, I've done this in the past where I directly worked at the root level for a site that wasn't active and all worked well.
Is there any way that (perhaps in web.config) I can tell it that any time I set MasterPageFile= "~/Master/masterPage.master" on a page it should actually point to MasterPageFile= "~/sandbox/Master/masterPage.master" ? I was under the impression that the "~" would take care of that, but apparently not?
Based on Google searches, I have found that in Web Applications (rather than Web Sites) there is a way to define the 'Web' part, but that option does not seem to be available here...
Any help would be greatly appreciated.
Thanks,
JoeE
EDIT:
So, I'm told this looks like a "wall of text" (whatever that may mean)... Let me give more details with a step by step for an example, perhaps someone can slap me in the right direction.
Right-Click on the Item under the Solution and Add>Master Page, then edit the MasterPage.master to have this content:
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
Some Content from Master
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Add>Web Form (Default) and edit its contents to read:
<%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/MasterPage.master" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server" >
<p>Some Data from Page</p>
</asp:Content>
Now I Test Run it at this point with F5 and I get a browser window that says "Some Data from Page"... as expected.
Now comes the time to upload it to my server (hosted by 1&1):
When I click Publish, it takes me to the Default.aspx page but states:
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 '/MasterPage.master' does not exist.
Source Error:
Line 1: <%@ Page Language="VB" AutoEventWireup="false" MasterPageFile="~/MasterPage.master" CodeFile="Default.aspx.vb" Inherits="_Default" %>
Line 2:
Line 3: <asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server" >
Source File: /sandbox/siteTest/Default.aspx Line: 1
My question is this: where do I need to tell Visual Studio that the folder structure really contains everything under the "/sandbox/" folder rather than just "/"? I understand that I can go into the Default.aspx file and change the statement to MasterPageFile="~/sandbox/MasterPage.master"
but there -has to be- a better way...?? I was expecting that the entry in the Publish option would do this, but it doesn't... alternatively, I tried to programmatically change this during the PreInit event, but that didn't work...
Thanks,J
Alright... I think I found a solution. Perhaps just a touch bit hack-y, but it works for what I need and hopefully someone else might find this useful. After trying some other options, the one that works for what I need is to keep the structure as-is but to use a subdomain for the testing. So now I publish to sandbox.example.com rather than example.com/sandbox The server now considers the "~/" folder to actually be where I point the subdomain to.
Thanks for the effort & feedback.