Is there an alternative to define("BASE_PATH", "http://localhost");
for PHP in ASP.NET C#?
I've been searching online for hours, yet most results give me 'definitions' of asp.net, or php, or alternative (lol?).
Thank you
Use a static or a constant of appropriate visibility to the use in question.
For a base path, Request.ApplicationPath
may be more useful than something hard-coded.
这做同样的事情:
const string BASE_PATH = "http://localhost";
define
is a constant assignment in PHP
. Since ASP.NET is object-oriented language you assingn constants something like
class YourCSharpClass{
const string ConstName = <value>;
}
But I think you assign some special meaning to those BASE_PATH
variable. Are you using Windows.Forms or ASP.NET MVC?
I've never seen this before but looking it up it seems like this definition is only used for prepanding aa url? Do you need to do this can't you make everything relative?
Alterantively you could probably use the AppSettings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.