3

Attempting my first "HELLO WORLD" type web app which I based on a sample program that showed godaddy setup.

Using visual studio 2017 and C#. My program builds and runs just fine at localhost/xxxxx but fails when I attempt to publish it. Error says

Parser Error Message: The file '/Site.Master' does not exist

Googling I read a suggestion to use "./" instead of what VS2017 created":

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BoincStats._Default" %>

So I changed that tilde to a dot and not only do I get a new error

BoincStats.SiteMaster not found

but I also discover that it does no longer runs on my Windows-10-x64 system unless I put the "~/" back in.

The same googling suggested replacing CodeBehind with CodeFile which failed to even publish.

For a starter, I would like to know difference between those functions and when to use them.

In Ubuntu, I have executed mkdir "~/vnc" and it makes a hidden directory in my root named vnc. Looking at the remote website (godaddy) and my local drive, I do not see any directory "Site.Master" only a file at "JTest" where it got installed.
VS and FileZilla

Peter B
  • 22,460
  • 5
  • 32
  • 69
  • You should also tag this question with either `asp.net` or `asp.net-core`, depending on which one you're using. I assume Core since you mention Ubuntu, and the meaning of `~` to an operation system is very different from how ASP.NET (any version) interprets it. – McGuireV10 Apr 27 '18 at 23:06
  • 1
    In ASP.NET, the tilde is shorthand for the site root. That way you don't have to change anything when debugging on `https://localhost` or deploying to `https://foo.com`. – McGuireV10 Apr 27 '18 at 23:08
  • `.` is web url route but if you have a sub directory is will not consider this aka same same, but if your site is www.goo.com/sysadmin/ in other words you have different apps for www.goo.com/ and www.goo.com/sysadmin/ then i believe if you were deployed in sysadmin and you used `.` it would nav you to www.goo.com/ in stead of www.goo.com/sysadmin/ i think it become applicable for sub directory hosting mostly. I could be wrong but this is what my understanding is. – Seabizkit Feb 03 '20 at 09:43

1 Answers1

1
  1. ~/ refers to the application root directory, whereas ./ refers to the file's directory. This notation is also implemented in methods such as @Url.Content() and Server.MapPath().

  2. As for CodeFile vs. CodeBehind, see this answer.

devio
  • 36,858
  • 7
  • 80
  • 143
  • 1
    Just a note: you tagged this question `asp.net-core` but MasterPages are exclusive to ASP.NET WebForms (.NET Framework upto 4.x) and do not exist in .NET Core; for that reason I re-tagged it. – Peter B Feb 03 '20 at 12:12